The !LOOP variable is especially useful together with the POS attribute of the TAG command for iterating over elements on a page, e.g. search result links.
You can also explicitly SET a value for !LOOP at the beginning of the macro to force a different starting value (the default value is 1). For example, you might use SET !LOOP 2 if you are using the !LOOP variable with SET !DATASOURCE_LINE to control the current line/row of an input file and you want it to skip the header row.
Any integer 1,2,3,4,5,....
* There is a demo video. * Related example macros: Demo-Slideshow
- The command to explicitly set the value of !LOOP is only executed once. So if you use the following to e.g. skip the header row of an input file, it will be ignored for every loop run except the first one.
SET !LOOP 2
- The !LOOP variable is never set as a result of calling a macro using the scripting interface (iimPlay). It is only set when playing the macro directly from the sidebar or from the command line using the -loop switch. To loop a macro using the scripting interface, the user must setup the loop using whatever loop construct is appropriate for the scripting/programming language they are using, and pass in their own user-defined loop variable to the macro. See VBS looping for a quick VBScript example.