# How Actions Execute

Actions are one of the most powerful features in Yate. It is important to understand how actions execute in order to get the most out of them.

Actions are run in two primary modes. Interactive mode and batch mode.

In Interactive mode actions operate on the currently selected files and can present prompts. When a prompt is displayed you to can make changes to the currently selected files. Prompts are presented in the Action Pending window or various dialogs invoked by various prompt functions.

Batch mode is the operational state when running an action from the Batch Processor Wizard. Typically there is little or no user interaction while an action executes in this mode.

Actions can be cancelled by selecting Cancel from the Yate menu or via the Cancel toolbar button. Note that when cancelling an action run interactively, it can take more than five seconds before the cancellation occurs.

By default, an action, regardless of the primary mode, executes in what is called Stepwise execution. This means that every step, or function, in an action executes over all the selected files before proceeding to the next step. This mode enables the processing of functions which are file independent such as the various database functions and most artwork related functions. Some action functions limit track access to a single file while in stepwise mode. When this is the case it is documented in an action function's help.

Think of Stepwise mode as executing a given function in parallel across all selected files. The statement:

> Copy the Variable 1 field to Variable 2

will copy each tracks' Variable 1 field to its Variable 2 field.

When action processing first starts you are always running in Stepwise mode.

The Stepwise execution mode does in certain circumstances limit the types of things you can do on a per file basis. For this reason Grouped execution was added.

When an action is run in Grouped execution, the entire action and the actions it calls, are run as a single group. When the entire group is finished for a single selected file, the group will be run against the next selected file, then the next, until all the selected files have been processed. Think of a Grouped action as a single function in Stepwise mode. Grouped execution is useful when you have to perform a number of successive operations on a single file before proceeding to the next file.

Actions can be written to operate in stepwise and grouped execution modes. If fact the current execution context can be tested while the action is running. As we've already mentioned, an action started from the user interface is in Stepwise mode. When an action calls another, the current mode is carried over by default.

Grouped execution of an action can be started in a number of ways:

- Any action run while already in grouped mode will always run in grouped mode.
- From the Run function when the Run Grouped option is specified.
- From the Test function when the Grouped option is specified.
- From the Repeat For function when the Grouped option is specified.
- From the Repeat With function when the Grouped option is specified.
- By encountering a Force Group Execution function as the first step an action. This is useful to ensure that an action is always run Grouped.

Note that actions running Stepwise can run Grouped actions but that actions running Grouped cannot run Stepwise actions.

When executing Grouped you will not have the option of specifying Skip for all files in a Action Pending window.

If you are writing an action which performs operations without actually using any selected audio files, it is may be desirable to ensure that the action is only executed once, regardless as to how many files are selected. In this case you can use the Constrain Execution to a Single File statement. The statement commits you to running as if only one audio file was selected. The Run, Repeat For, Repeat With and Test statements all support a Grouped-Once mode which effectively does the same as the Constrain statement but is non committal.

Various action statements can be used to limit or expand the set of files which are available when executing Stepwise. The File Availability topic probides additional information.

You can save settings for an action in a persistent form called Action Runtime Settings. More information can be found in the Action Runtime Settings topic.

Additional topics:

Actions

Flow Control

Variables

Data Types

The following action statements are used to control the set of available files:

Active Files to List

Constrain Execution to a Single File

Expand Execution to Unselected Files

Ignore Files

List to Active FIles

Restore Initial Set of Files

The following action statements are used to run sub-actions or to modify how files are processed:

Force Grouped Execution

Load & Run

Repeat Forever

Repeat With

Run

Test & Run