EndLoop is the marker where the code block of the loop ends. The macro code between Loop and EndLoop has to be executed until the loop exits. ExitLoop breaks the loop immediately at this position and the macro continues with the command after EndLoop. So ExitLoop is just a JUMP to command after EndLoop.
It's also possible to run a loop without ExitLoop command if you need a defined number of loop execution. For example a simple loop macro to place the cursor at column 70 in the current line:
Key RIGHT ARROW
Your macro will also fail because you have nested loops - loop inside an existing loop. This is not possible in UE macro language.
IfNameIs "" means if the current file name is NULL which is true if no file is open or the current file is a new file which does not have a name until first save. So if you have only named files open, my macro exits after all files were modified and closed.
Well, this method will not work if you don't close a file if it does not contain the search term. You will produce an endless loop in this case because there will be always at least one file opened which has a name.
IfFound and IfNotFound can be used after a Find or Replace. It is possible to have other commands between Find/Replace and IfFound/IfNotFound although usually the condition commands are immediately after the Find/Replace command. The Replace command must be always immediately after the Find command. The IfFound/IfNotFound command must be below the Replace command and can be never between Find and Replace.
You can use ExitLoop as often as you want inside a loop.
ExitMacro at the end of the macro is useless because if there are no more macro commands the macro automatically ends. ExitMacro is only for exiting the macro execution anywhere inside the macro.
If you use IF conditions you have to write also the EndIf command for every IF condition or UE does not know which commands are for the current IF condition. An Example:
- Code: Select all
In comparison to loops nesting of IF conditions is possible as you can see. Every command in this example can be also an ExitLoop command if this code block is inside a loop.
Note: Indenting the commands in the edit macro dialog is not possible. This example here is just for better understanding.
If you check the macro property Continue if a Find with Replace not found
my macro will also work for files which does not contain the search term. Those files are also saved and closed although nothing is changed by the macro because the string was not found.
If you must know which files do not contain the search string and you want those files open after the macro execution use following macro with macro property Continue if a Find with Replace not found
checked. It collects the file names with path of the files without the search string in user clipboard 9 and after first loop has finished and all open files are closed the macro runs a second loop to open the files without the search string. Make sure there is no space after first " at the 2 lines with only " before you copy the code into the edit macro dialog."
is the macro code to insert a line break to have later only one file name with path per line.
Here is the extended macro code which reopens the files which does not contain the search string. Make sure all files are saved before starting the macro or use SaveAll macro command before first loop because files without the search string are temporarily modified and so closed without saving (what you could also change) to not change the file time.
Find MatchCase MatchWord "TEST"
Find MatchCase MatchWord "TEST"