GotoLine with ^c

GotoLine with ^c

6
NewbieNewbie
6

    11:15 - 1 day ago#1

    Can I use "^c" with "GotoLine"? can anyone say

    Code: Select all

    InsertMode
    ColumnModeOff
    HexOff
    PerlReOn
    Find RegExp "(?<=\[)(.*?)(?=\])"
    IfFound
    Copy
    NextWindow
    UltraEditReOn
    GotoLine ^c
    This is a sample
    00500000IHRFC8.xml [15:21] : Error: premature end to content of element 'title1'. Expecting child element 'b'

    6,686585
    Grand MasterGrand Master
    6,686585

      14:45 - 1 day ago#2

      No! The placeholder ^c is supported only by the macro commands Find, Replace, FindInFiles, ReplaceInFiles in search/replace strings of a non-regular expression or an UltraEdit regular expression find/replace (in files) and by Open and SaveAs in the file name string.

      There can be used an UltraEdit script for this task.

      Code: Select all

      if (UltraEdit.document.length > 0)  // Is any file opened?
      {
         // Define environment for this script.
         UltraEdit.insertMode();
         if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
         else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
      
         // Define the parameters for a case-sensitive Perl regular expression
         // find from current position in the active file to end of the file.
         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;
         }
         if(UltraEdit.activeDocument.findReplace.find("^.+?\\[[0-9]+:[0-9]+\\]"))
         {
            // Get file name, line and column number from the found string.
            var sFileName = UltraEdit.activeDocument.selection.replace(/ \[[0-9]+:[0-9]+\]/,"");
            var sLineNumber = UltraEdit.activeDocument.selection.replace(/^.+\[([0-9]+):[0-9]+\]/,"$1");
            var sColumnNumber = UltraEdit.activeDocument.selection.replace(/^.+\[[0-9]+:([0-9]+)\]/,"$1");
      
            var nDocIndex;
            // Search in the list of opened documents for the file.
            for (nDocIndex = 0; nDocIndex < UltraEdit.document.length; nDocIndex++)
            {
               // Get just the string after last backslash of the absolute file name.
               var nDocName = UltraEdit.document[nDocIndex].path.replace(/^.+\\/,"");
               if (nDocName == sFileName) // This string comparison is case-sensitive!
               {
                  UltraEdit.document[nDocIndex].setActive();
                  break;
               }
            }
      
            // Is the file not already opened, try to open it.
            // That works for a file name without path only if the current working
            // directory of UltraEdit/UEStudio is the directory containing the file.
            if (nDocIndex == UltraEdit.document.length)
            {
               UltraEdit.open(sFileName);
               // The opened file becomes automatically the active file on success.
            }
      
            // Is the file opened now?
            if (nDocIndex < UltraEdit.document.length)
            {
               // Convert the line and column number to integers and
               // set the caret in active file to that line and column.
               var nLineNumber = parseInt(sLineNumber,10);
               var nColumnNumber = parseInt(sColumnNumber,10);
               UltraEdit.activeDocument.gotoLine(nLineNumber,nColumnNumber);
            }
         }
      }
      
      Best regards from an UC/UE/UES for Windows user from Austria

      6
      NewbieNewbie
      6

        6:42 - 1 day ago#3

        Actually I asked for the macro because only this part of my macro didn't work so I only give this. But you gave the script.
        I wanted a macro that would work on 2 types of log files, the first one was working on the log file but the second file was not working, so only that part is given here.
        I give the whole macro if you can do something.

        6,686585
        Grand MasterGrand Master
        6,686585

          17:58 - 1 day ago#4

          I do not know what I should do. The entire macro code up to last EndIf does not make much sense on being run on the provided file. There is nothing changed on error.rpt. The script provided by me does also nothing on execution on contents of file error.rpt as there is no line beginning with an XML file name followed by a space, an opening square bracket, a line number, a colon number and a closing square bracket. The file contains just two lines with an XML file name at the beginning.

          Do you know that there can be right clicked anywhere inside the XML file name in error.rpt and left clicked in the opened context menu on first menu item Open "C:\Temp\00500000II9A00.xml" (or whatever is the current working directory path) for opening the file?

          It is even possible to open a file (or url) as stored in an opened file like error.rpt with caret (text cursor) at the beginning or in the middle of the file name by key on assigning a hotkey or chord to the command Open file/URL under cursor (command name as in UE v2024.1.0.36) in the key mapping configuration dialog window.
          Best regards from an UC/UE/UES for Windows user from Austria