Feb 17, 2018 #2 2018-02-17T17:44+00:00
The simple script without any comments:
Code: Select all
if (UltraEdit.document.length > 0)
{
UltraEdit.insertMode();
if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
UltraEdit.activeDocument.top();
UltraEdit.perlReOn();
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;
if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean")
{
UltraEdit.activeDocument.findReplace.searchInColumn=false;
}
var nNumber = 0;
var sLastId = "";
var nModCount = 0;
var nKeptCount = 0;
while (UltraEdit.activeDocument.findReplace.find('(?<=id=")p\\d{2}_s\\d{2}_c\\d{2}_s\\d{2}_\\d{2}_[#\\d]{2}(?=")'))
{
var sThisId = UltraEdit.activeDocument.selection.substr(0,19);
if (sLastId != sThisId)
{
nNumber = 0;
sLastId = sThisId;
}
nNumber++;
var sNumber = (nNumber < 10) ? "0" : "";
sNumber += nNumber.toString(10);
var sNewId = sThisId + sNumber;
if (sNewId != UltraEdit.activeDocument.selection)
{
UltraEdit.activeDocument.write(sNewId);
nModCount++;
}
else
{
UltraEdit.activeDocument.key("RIGHT ARROW");
nKeptCount++;
}
}
UltraEdit.activeDocument.top();
var nFoundCount = nModCount + nKeptCount;
UltraEdit.outputWindow.write("Updated " + nModCount + " and kept " + nKeptCount + " of " +
nFoundCount + " found identifier" + ((nFoundCount!=1) ? "s." : "."));
}
Best regards from an UC/UE/UES for Windows user from Austria