![]() |
![]() |
switchAnother flow control command |
||||
Usage | ||||
|
||||
Description | ||||
The switch command is based on the standard C 'switch' keyword.
It conditionally executes groups of commands chosen from a larger set of command groups. First <expression> is evaluated (<expression> is any arithmetic or string expression). Then the 'match', 'regexp', 'case' and 'default' labels are evaluated sequentially in the order of appearance. case(<value>)[:]<command> The <value> is evaluated and is compared against the result of <expression>. String comparison is case insensitive. If <value> is equal to <expression> then <command> is executed. Please note that <command> must be either a single instruction or an instruction block enclosed in braces. During or after <command> execution, if a break statement is encountered the execution of the switch is terminated, otherwise the next label is evaluated. If the -p (--passthrough) option is enabled, than the switch command will execute all the istructions blocks until a break statement is found. match(<value>)[:]<command> The <value> is expected to be a wildcard expression (wildcard characters being '*' and '?') that is matched in a case insensitive fashion against <expression>. If a match occurs, the related <command> is executed. The break statement is treated as in the case label. regexp(<value>)[:]<command> The <value> is expected to be a complete standard regular expression that is matched in a case insensitive fashion against <expression>. If a match occurs, the related <command> is executed. The break statement is treated as in the case label. default[:]<command> The default label is executed unconditionally if no previous label terminated execution with the break statement. |
||||
Switches | ||||
|
||||
Syntax Specification | ||||
|
||||
Examples | ||||
# Try to change the 1 below to 2 or 3 to see the results
|