Command group | Flag affected | Reversible | Execute on client | Platform(s) |
---|---|---|---|---|
Constructs | NO | NO | YES | All |
Switch expression
This command initiates a Switch method construct. You use a Switch statement to select a course of action from a set of options based on the value of a variable, expression or calculation. It is similar to an If–Else If construct although the performance of a Switch construct tends to be faster.
The first line of the construction contains the Switch command. This defines the variable, expression or calculation on which the choice of action will depend. Following the Switch command, the Case commands provide values which, if matched with the expression supplied in the Switch line, cause the methods between case lines to be executed.
You can nest multiple Switch statements, and embed other conditional statements such as If–Else constructs.