User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with writing and running scripts
3 posts Page 1 of 1
Hi,

how to alphabetical order sequence after specific text?

If found

Code: Select all
"sec@@"
"sec@@"
"sec@@"
"sec@@"
........
"sec@@"
"sec@@"
"sec@@"
"sec@@"

replace with

Code: Select all
"secA"
"secB"
"secC"
"secD"
........
"secZ"
"secAA"
"secBB"
"secCC"
The script code is so easy for this task that I save time and don't comment it.

Code: Select all
if (UltraEdit.document.length > 0)
{
   UltraEdit.insertMode();
   UltraEdit.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 asCharacters = ['A','B','C','D','E','F','G','H','I','J','K','L','M',
                       'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
   var nCharCount=1;
   var nCharacter=0;

   while(UltraEdit.activeDocument.findReplace.find("(?<=sec)@+"))
   {
      var sIdentifier="";
      for (var nCount=0; nCount < nCharCount; nCount++)
      {
         sIdentifier+=asCharacters[nCharacter];
      }
      UltraEdit.activeDocument.write(sIdentifier);
      if (++nCharacter >= asCharacters.length)
      {
         nCharacter=0;
         nCharCount++;
      }
   }
}

The character array can be modified to whatever you want.
Best regards from Austria
Thanks Mofi. :P
3 posts Page 1 of 1