Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.


// RGCNRAHC
//
if (UltraEdit.outputWindow.visible == false) { // open output window
UltraEdit.outputWindow.showWindow(true);
}
UltraEdit.outputWindow.clear(); // clear output window
var findString = UltraEdit.getString("String to find",1); // Get string to find
findString = findString + "(....)"; // Add a regular expression to capture next 4 characters
UltraEdit.activeDocument.top(); // go to top of active document
UltraEdit.perlReOn(); // Use Perl reg exp
UltraEdit.activeDocument.findReplace.regExp=true; // Use regExp for search
if(UltraEdit.activeDocument.findReplace.find(findString)) { // search for string, enter if, if found
var foundValue = UltraEdit.activeDocument.selection; // Get selected text
var foundChars = (new RegExp(findString)).exec(foundValue); // Re-execute regExp on found value to extract 4 bytes
var foundChars = foundChars[1]; // Get the tagged expression of 4 chars.
var hexChars = chr2hex(foundChars); // Convert from string to hex using chr2hex
UltraEdit.outputWindow.write("Searching for...........: " + findString);
UltraEdit.outputWindow.write("Chars to be hex escaped.: " + foundChars);
UltraEdit.outputWindow.write("Hex value...............: " + hexChars); // Write result into output window
// Now open a blank doc and cut the hexChars into the active clipboard
// You could write it into the active file, but sometimes you don't want the "changed attribute" to be set.
var activeDocIx = getActiveDocumentIndex(); // to be able to restore focus on active document
UltraEdit.newFile();
UltraEdit.activeDocument.write(hexChars);
UltraEdit.activeDocument.selectToTop();
UltraEdit.activeDocument.cut();
UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
UltraEdit.document[activeDocIx].setActive(); // restore focus
// now the hex value is on the clipboard
}
UltraEdit.outputWindow.showStatus=false;
function chr2hex(chrs) {
var hexDigits = '0123456789ABCDEF';
if((String(chrs).length==0) || (chrs==null)) {
return "";
}
var hexChars = "";
for(var i=0;i<String(chrs).length;i++) { // iterate depending on length of chrs
var dec = String(chrs).charCodeAt(i); // First convert to dec.
hexChars = hexChars + ( hexDigits[ dec >> 4 ] + hexDigits[ dec & 15 ] ); // convert to hex
}
return hexChars;
}
function getActiveDocumentIndex() { /* Find the tab index of the active document */
var tabindex = -1; /* start value */
for (i = 0; i < UltraEdit.document.length; i++)
{
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
return tabindex;
}Searching for...........: RGCN(....)
Chars to be hex escaped.: RAHC
Hex value...............: 52414843

