10.2. SWITCH statement

SWITCH statement is a control structure that executes one of several blocks of the statements depending on the value of an expression.


[DO] SWITCH <expression>
	CASE <const11>[,<const12>,...]
	[ CASE <const21>[,<const22>,...] ]

It evaluates <expression>, looks for it's value in CASE constants, and executes associated block of statements. If none of the CASE constants are equal to the expression value, it executes the block of statements following the OTHERWISE statement (if exist).

Only numeric and character constants are allowed in CASE statement.


SWITCH is more effective than similar DO CASE statement.