This statement allows you to call an action a specific number of times. This statement is analogous to a typical for statement in a traditional programming language.
A variable or named variable is specified to contain the current value.
You specify start and stop values. If the adjustment value is not specified, 1 is assumed. The three value fields may contain any of the escape sequences described in Escape Sequences. At run time each of the fields is read as a signed integer value. The current value is initialized to the start value. The adjustment value is effectively added to the current value at the end of each full iteration.
You also specify a test condition used to compare the current value with the stop value. The repeat process terminates when the comparison is false. The comparison test is performed at the start of each iteration. Note that if the adjustment value evaluates to 0 at runtime, no repeating will occur.
Note that all control values are evaluated once. Changing the value of the current value track or named variable's contents will have no effect on subsequent iterations. Neither will changing the termination condition. Further, be careful when using track variables in the start, stop or increment values as they will be read from a single file. This is to ensure that there is a consistant execution profile for all files processed by the action.
The execution profile is as follows:
- Initial mode stepwise, designated action does not specify Run Grouped
- The designated action will be run once for each valid value in the specified range.
- Initial mode stepwise, designated action specifies Run Grouped
- The designated action will be run with the first value for each selected file. It will then be run with the second value for each selected file. etc. For three generated values and ten selected files, the action will be run thirty times.
- Initial mode grouped
- The designated action will be run once for each value.
When Run Grouped is selected, you can choose to run the action only once. The effect is that only a single file is processed. This is useful when the repeated action is processing data which is independent of the metadata in the tracks. For example you might be enumerating the ros in a query database. This combination of options is similar to the Constrain Execution to a Single File statement.
Note that if the designated action contains a Force Grouped statement, it is equivalent to specifying the Run grouped option.
Note also, that regardless of the execution mode, an Exit Repeat statement will terminate all repeating.
The Repeat For statement can specify that the named action is inline. When Inline is specified there must be a Start statement inside the current action with the specified name.
The Indirect option enables the use of Escape Sequences in the text field where you specify the name of the action to be run. This enables you to choose the action to be run based on the contents of variables or any other constructed pattern. The action name is only validated at run time. If the evaluated name is empty, the Repeat For statement is ignored. You can setup lists using the various list statements to contain the names of actions; inline or not. By using the List Item At Index/Sublist statement, you can pull an action name and place it in a variable which can then be specified in the Repeat For statement.
Example: Repeat For named variable 'index' = '0' while < '\<Query Database-Row Count>' by '1' Run inline action 'Process Database Row' grouped (once)
The inline Process Database Row action will be successively called with named variable index for every row in Query Database.
If you change the file availability while executing under the control of a Repeat With or Repeat For statement, make sure you restore the available files to those available when the Repeat statement was started. If you do not, the execution flow may be unpredictable.