Hi experts,
last time Mofi helped me to develop this code for repacing 0000 to XX00 at the beginning of a line:
Now I want to add new code that deletes the rest of each line at position 15 to the end (of line).
I asked ChatGPT and this was the answer:
But, I don't know how to integrate this new code.
Maybe you can help me?
last time Mofi helped me to develop this code for repacing 0000 to XX00 at the beginning of a line:
Code: Select all
UltraEdit.activeDocument.top();
if (UltraEdit.document.length > 0) // Is any file opened?
{
// Define environment for this script.
UltraEdit.insertMode();
// UltraEdit.columnModeOff() is for UltraEdit for Window while
// UltraEdit.activeDocument.columnModeOff() is for UltraEdit for Linux/Mac.
if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
// Move caret to top of the active file.
UltraEdit.activeDocument.top();
// Define all parameters for an UltraEdit regular expression replace
// all in entire active file searching for the string 0000 at beginning
// of a line and replace each found occurrence with the string AB.
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
UltraEdit.activeDocument.findReplace.searchDown=true;
// The IF condition is for UltraEdit version 13.xx which does not have
// the search in column feature. Just the line inside the IF condition
// is needed on newer versions of UltraEdit.
if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean")
{
UltraEdit.activeDocument.findReplace.searchInColumn=false;
}
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.ueReOn(); // UltraEdit regular expression engine
UltraEdit.activeDocument.findReplace.replace("%0000", "XX");
}
I asked ChatGPT and this was the answer:
Code: Select all
UltraEdit.activeDocument.top();
while (!UltraEdit.activeDocument.isEof()) {
if (UltraEdit.activeDocument.currentPos > 14) {
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 14);
UltraEdit.activeDocument.selectToEOL();
UltraEdit.activeDocument.deleteSelection();
}
UltraEdit.activeDocument.key("DOWN");
}
Maybe you can help me?