# Run

This statement is used to run an action from within an action. This can be used to make complicated actions easier to understand and also makes it easier to reuse common action sequences.

While running actions, a stack is maintained with the name of every action currently running. It is not permitted to have the same action on the stack more than once. This means, for you programmers out there, that recursion and cyclic references are not permitted.

When a new action is run, the current execution mode is maintained. This means that if the current action is being run stepwise, the new action will run stepwise. If the current action is being run grouped, the new action will run grouped. The Run grouped option can be used to force the specified action to run grouped.

The Run statement can specify that the named action is inline. When Run 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 any constructed pattern. The action name is only validated at run time. If the evaluated name is empty, the Run 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 Run statement.

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 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.

You can also choose to only process those files which have a specific track variable with a value of true (non zero integer). This enables you to preset condictions which determine if a specific file gets processed. Example: Process files where the Title field starts with "The". The semantics are what you would expect for both stepwise and grouped execution modes. Regardless of the execution mode, only those files with the specified track variable having a value of true will get processed. Changing the control variable in the called action will not change which files get processed. When selecting files to be processed with this option you can only save the chosen files. See the Save statement for more information. Note: The Run statement, when testing a track variable, is the only means of possibly executing an action zero times.

- Test if the Title field starts with "The" case insensitive (Set result and Variable 1)
- Run inline action 'Process' grouped if Variable 1 is true
- Start Process - Only Called for files where Title starts with "The"

Note that when processing files which have a specific track variable, the Once option may not have the desired effect. Once is applied before the variable testing is performed. This means that if the first file tested does not have the variable with a value of true, the processing will be stopped. To handle this case do not use Once and place a Break statement in the action itself.