Tapatalk

How to see the currently loaded macro(s)?

How to see the currently loaded macro(s)?

5
NewbieNewbie
5

    Nov 28, 2017#1

    Is there a way to display the currently loaded macro?

    I have a few macros which are used continually. I haven't found a way to effectively combine them based on their individual function. It would be really helpful to know which one is currently loaded.

    6,685587
    Grand MasterGrand Master
    6,685587

      Nov 28, 2017#2

      A macro file can contain multiple macros and not just one macro. You can merge the existing macros stored in individual macro files by clicking in ribbon mode on ribbon tab Advanced in group Macro on down arrow left to item Load and use from popup menu the menu item Load and append to existing.

      After loading all the macros from the macro files into memory click on down arrow left to Configure in group Macro and click on menu item Configure macros. You can modify in this dialog the names of the loaded macros, their two check box properties and the hotkeys/chords for execution by key.

      Once all loaded macros are configured well, click on down arrow left to Configure in group Macro and click on menu item Save all macros. All loaded macros are saved now into one macro file. When you often need those macros, it would be best to configure this macro file to be loaded automatically on startup of UltraEdit. This can be done by clicking on on down arrow left to Configure in group Macro and clicking on menu item Set macro for auto-load.

      If the macros should be executed usually automatically in series, it is possible to create a macro which contains the macro command PlayMacro 1 "Macro Name" several times. The macro to play 1 times must be stored in same macro file. Each submacro is played in then environment (check box properties) defined for master macro calling them with PlayMacro command. The macro file with the ultimate syntax highlighting tools is a public available example containing multiple macros with some macros being submacros of other macros in macro file and being executed conditionally.

      To answer your question:

      On using ribbon mode click on ribbon tab Layout in group Views on check box item Macro list. This list view shows the macros currently loaded. Double clicking on a macro in this list executes the macro on active file once. This list view can be floating or docked on any side without or with auto-hide enabled as all other list views.
      Best regards from an UC/UE/UES for Windows user from Austria

      5
      NewbieNewbie
      5

        Nov 28, 2017#3

        Using a specific example - I have one macro that does a series of "Replace All" commands based on static recurring patterns - I play this macro once per file. A second macro acts on each line finding a specific string then applying an action. But this one has to be run a specific number of times and not past EOF.(UE (or something about the way I code\run my macros) seems to have a habit of running some types of macro commands "past" EOF resulting in it backing up and modifying previous lines of text). Given this example I don't see how I could run these concurrently.

        However moving on to displaying the currently loaded macro, after loading these two macros I checked the macro list view and see none listed - see attached "macro-list.png"

        Thanks!
        macro-list.PNG (18.13KiB)

        6,685587
        Grand MasterGrand Master
        6,685587

          Nov 28, 2017#4

          Open Advanced - Settings or Configuration - Search - Miscellaneous and you can see the setting Continue find at end of file. This setting is by default checked. In this case a find/replace downwards continues at top of file if the searched string can't be found from current position of caret to end of file (wrap to top). And with this setting enabled a find/replace upwards continues at end of file if the searched string can't be found from current position of caret to top of file (wrap to bottom). I have this setting unchecked as I prefer to search always from current position to end/top of file without wrapping around. But this means for a search on entire file I have to move the caret to top of file with Ctrl+Home before starting.

          But the find/replace behavior on running a macro or script is different as it never wraps around. In other words the state of setting Continue find at end of file is pushed on stack on starting a macro/script, then the configuration setting is internally in memory of UltraEdit disabled, and after script/macro execution finished (as expected or because of an error does not matter), the state of this setting is popped from stack to restore its configured value. This behavior avoids endless running macros or scripts.

          The replace dialog has also the option Replace all is from top of file. This setting is never enabled during macro/script execution. So every Replace All executed from within a macro/script is always from current position of caret in file to end of file. A Replace All never moves the caret in file. Well, there are some versions of UltraEdit which have a bug resulting in a Perl regular expression Replace All executed from within a macro/script moved the caret in file to last occurrence of replaced string. This was a bug which was fixed after I detected and reported it. The workaround for this bug is simply moving in macro/script the caret to top of file with the Top command after every Perl regular expression Replace All execution.

          There is the macro command IfEof which can be used to exit a loop executed an undetermined number of times. But this command returns true only if the caret reaches the end of the file. A find for a string not found once more from current caret position in file to end of file does not move the caret to end of file. For this case the command IfEof can't be used in most cases to run a macro on multiple positions in a file until end of file is reached as the caret never reaches the end of the file.

          I explain all those details in the macro reference for beginners and experts.

          I suppose for your two macros the required macro code would be something like:

          Code: Select all

          InsertMode
          ColumnModeOff
          HexOff
          UltraEditReOn
          Top
          Find "Search String 1"
          Replace All "Replace String 1"
          Find "Search String 2"
          Replace All "Replace String 2"
          ... more Find and Replace All.
          Loop 0
          Find "Search String x"
          IfNotFound
          ExitLoop
          EndIf
          ... Commands to execute on line containing the string.
          EndLoop
          Top
          ... Other commands to finish file reformatting.
          Loop with value 0 means run the loop undetermined number of times. The command ExitLoop breaks the loop execution which is executed if the string searched for is not found anymore from current position of caret in file to end of file independent on configured state of setting Continue find at end of file.

          The empty Macro list is a result of either no macro file with one or more macros loaded or the macro(s) were created in the past using Quick Record instead of Record. The command Record first opens the Macro Definition dialog in which a macro name can be entered, the two macro properties can be configured and the hotkey/chord can be defined before starting macro recording. The command Quick Record does not open this dialog and instead immediately starts recording the macro with no name, both macro properties checked and no hotkey/chord assigned to the macro.

          However, the Modify Macro dialog can be opened in ribbon mode by clicking on ribbon tab Advanced in ribbon group Macro on down arrow left to item Configure and clicking next on menu item Configure macros. In this dialog a click on button Rename can be performed for each macro in list with an empty string as name to define now a suitable name for the macro. The properties for the selected macro can be also modified in this dialog. Once (all) macro(s) have been modified, the command to Save all macros as described in my previous post must be executed to save all those modifications on macro properties also into macro file.
          Best regards from an UC/UE/UES for Windows user from Austria