Switch – Visara Master Console Center Scripting Guide User Manual
Page 196
![background image](https://www.manualsdir.com/files/808700/content/doc196.png)
Chapter 5 Script Commands
Scripting Guide
196
SWITCH
Syntax:
SWITCH...CASE...[DEFAULT...]ENDSWITCH
SWITCH Expression
CASE
SimpleExpr:
[commands]
[BREAK]
[CASE
SimpleExpr:]
[commands]
[BREAK]
[DEFAULT:]
[commands]
[BREAK]
ENDSWITCH
Description:
Execute command(s) based on the value of an expression.
Action:
Each CASE Simple Expression is evaluated and compared (one by one
in the listed order) to the Expression.
-
If the comparison evaluates to TRUE, the command(s) for that
CASE statement are executed.
-
If the BREAK statement is not present in the CASE command
block, the commands in all subsequent CASE command blocks are
also executed (regardless of each subsequent CASE statement as
they are not evaluated). Execution continues until a BREAK or
ENDSWITCH statement is encountered.
-
If no comparison evaluates to TRUE, then, if present, the
DEFAULT command statements are executed.
Parameters:
Expression. Numeric or string expression. The evaluated expression
to compare to each CASE statement.
SimpleExpr. Numeric or string simple expression. A numeric or
string literal or variable compared to the expression.
DEFAULT. Keyword. Optional. The command block that is executed
when none of the comparisons matched.
Returns:
N/A.
Notes:
1. The expression type that each expression evaluates to must match
the variable type with which it is being compared.
2. Once execution of commands in a CASE statement has begun, the
BREAK statement ends it and prevents the statements in the next
CASE block from being executed. No other statement ends
execution.
3. DEFAULT, if specified, must be the last case statement.
4. The maximum number of CASE statements per SWITCH command
is unlimited.
5. The maximum number of nested SWITCH() commands is 256.