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.