# Flow Control in Actions

By default an action executes from its first statement until its last statement is done and then it returns. If the action was called by another action it will resume processing after the calling statement.

The above statement is a simplification as obviously the current and previous execution modes, Stepwise or Grouped also affect what happens when you return. When you return from an action running Stepwise you will still be running Stepwise. When you return from an action running Grouped the previous execution mode will be continued. For example, if Stepwise action A calls Grouped action B, the execution mode will be set to Stepwise when B returns. However, if Grouped action C calls Grouped action D, the execution mode will be still be Grouped when D returns.

Previous versions of Yate maintained an action test state for each action. The action test state is set or cleared by various statements and can be manually set via the Set Action Test State function. When an action terminated, its test state did not carry back to the calling action. Current versions of the application maintain a single action test state which is only automatically reset to False when a UI based action starts or when the Batch Processor is about to process a new folder. This behaviour can be changed in Preferences-Actions and at runtime via the Preferences statement.

The most basic flow control statement is the standard if - else - endif construct. In Yate, the if statement tests if the action test state is true or false. The if-else-endif construct allows you to selectively execute action statements.

Actions may invoke other actions. The Run statement is used to unconditionally execute another action.

The Test function allows you to test the current action test state and based on the results of the test optionally execute another action. You can then optionally Exit (return from the current action) or Stop (terminate all action processing).

The Load and Run statement will load an audio file and execute an action against the file. This statement is only valid while batch processing.

Exit is a stand alone function which conditionally performs an effective return at a specific location in the action.

Stop, Stop Batch Processing and Cancel statements all conditionally terminate action processing, regardless of how many nested actions are running.

The Repeat With statement can be used to successively call an action, setting a variable to successive portions of a field. Think of it as successively processing all elements in a list.

The Repeat Forever statement can be used to repeat until stopped by an Exit, Exit Grouped, Exit Repeat, Stop, Stop Batch Processing or Cancel statement. The statement is only valid while batch processing.

The Next File statement conditionally stops the execution of the current action and proceeds to processing the next file to be processed. While executing Stepwise, the function is identical to the Exit function. While executing Grouped, the function essentially successively returns to the outermost called action which can begin processing the next file.

The Exit Grouped statement conditionally stops the execution of all actions being run Grouped. While executing Stepwise, the function is identical to the Exit function. While executing Grouped, the function essentially successively returns to the outermost action running Stepwise. If all actions are being run Grouped, action processing will terminate.

The Exit Repeat statement conditionally exits the current action. If the action is being directly run by a Repeat With or Repeat Forever statement, it will stop the current repeat sequence.

The Break statement conditionally exits the current action, regardless as to how it was called or whether the execution mode is stepwise or grouped. The next statement to be executed is always the statement immediately following the caller.

For a detailed explanation as to how actions execute:

How Actions Execute