User Tools

Site Tools


action:Switch_or_Case

Switch/Case Action

The Switch/Case action is used to perform different actions based on different values of a common parameter. It is very similar to the JavaScript Switch statement.

The Switch Action is a good alternative to using multiple, nested, If/Then Actions.

Parameters

The Switch parameter may be any of the following:

Default Configuration

When you insert the Switch Action, it is configured to switch based on the System Clipboard, but can be easily changed to other parameters. It initially looks like this:

For each Condition that you add, you can enter zero or more Actions that will be executed when that Condition is met. After those Action(s) are executed, or if no Conditions are met, the Switch Action is exited.


Example

See this Forum Topic for a downloadable example:
ACTION: Switch Case Based on FrontMost App

Conditions

The Conditions available depend on the Parameter that is chosen:

The Conditions are defined as follows:

ConditionDefinition
has text Clipboard has at least one item containing text of some sort.
does not have text Clipboard does not have any text items.
has image Clipboard has one or more images.
does not have image Clipboard does not have any images.
is is exactly (case insensitive) the specified string.
is not is not exactly (case insensitive) the specified string.
is before is alphabetically before the specified string. (v7.2+)
is after is alphabetically after the specified string. (v7.2+)
contains contains (case insensitive) the specified string.
does not contain does not contain (case insensitive) the specified string.
matches matches the specified regular expression.
does not match does not match the specified regular expression.
conforms to Clipboard has an item with the UTI class that conforms to the specified Uniform Type Identifier.
does not conform to Clipboard does not have an item with the UTI class that conforms to the specified Uniform Type Identifier.
otherwise will execute if none of the Conditions in the Switch, that are entered above otherwise, are met.

The Otherwise Condition will execute if none of the above Conditions are met. The Switch Action will then exit. So, the Otherwise Condition should always be placed as the last Condition in the Switch Action.


See Also

Actions

Conditions

Forum

action/Switch_or_Case.txt · Last modified: 2017/09/26 01:16 by peternlewis