Application icon

Repeat With

This statement allows you to enumerate elements in lists. A list can be items separated by a delimiter or a string where every character is a list item.

The execution profile is as follows. Note that the term list item is used loosely to represent an element of a list or a single character from a string.

Initial mode stepwise, designated action does not specify Run grouped
The designated action will be run once with each list element. For three unique items, regardless of the number of selected files, the action will be run three times.
Initial mode stepwise, designated action specifies Run grouped
The designated action will be run with the first list element for each selected file. It will then be run with the second list element for each selected file. etc. For three unique items and ten selected files, the action will be run thirty times.
Initial mode grouped
The designated action will be run once for each list element. For three unique items and one file (by definition), the action will be run three times.

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 processing a query database or a list. 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 With 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 track variables or any other constructed pattern. The action name is only validated at run time. If the evaluated name is empty, the Repeat With 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 track variable which can then be specified in the Repeat With statement.

Note that changing the list or source string's contents once the Repeat With statement is started, will have no effect on the loop's execution. Changing the value of the current track or named variable's contents will also have no effect on subsequent iterations. The effective list is only calculated once per set of files. Unless the initial list items are in a named variable, you more than likely want to run grouped.

Example: Repeat With Variable 1 for the list in field Genre (Sort) (Case Insensitive) string delimiter ',' Run action test

If all the files have a Genre field of Blues, Blues Rock, Rock, action test will be successively called with Variable 1 set to Blues, then Blues Rock, then Rock.

Example: Repeat With Variable 1 for every character in named variable test Run inline action 'test' grouped

If the named variable test contains Rock, action test will be successively called with Variable 1 set to R, then o , then c, then k.


Warning Please Read

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.