User Guide

Crestron SIMPL+
®
Software
Language Reference Guide - DOC. 5797G SIMPL+
®
z 91
SWITCH
Name:
SWITCH
Syntax:
SWITCH (<expression>)
{
CASE (<expression1>):
[{]
<statements1>
[}]
CASE (<expression2>):
[{]
<statements2>
[}]
[DEFAULT:
[{]
<statements>
[}]
}
Description:
SWITCH is a more direct method of writing a complex IF-ELSE-IF statement. In the
SWITCH, if <expression> is equal to <expression1>, <statements1> is executed. If
<expression> is equal to <expression2>, <statements2> is executed. This same
method would apply to as many CASE statements as are listed in the body of the
SWITCH. Note that if any of the <statements> blocks are only a single statement, the
{ and } characters on the CASE may be omitted.
SWITCH has the restriction that the expressions may not be STRING expressions,
they can only be INTEGER type expressions. SWITCH may only have up to 32
CASE statements in SIMPL+ Version 1.00. If more are used, a “FULL STACK”
error results at the time of uploading the module to the control system. Version 2.00
has no restriction.
When a SWITCH is evaluated, the first matching CASE is used. If another CASE (or
more) would have matched, only the first one is used. If no condition is met in the
CASE statements, the DEFAULT case is used if specified.
NOTE: Many CASE statements may be used in the body of the SWITCH.