SWITCH – CASE – DEFAULT

The SWITCH-CASE-DEFAULT control structure is a simplified form of the IF-THEN-ELSIF-ELSE-ENDIF control structure and is used when numerous branches are to be enabled.

The syntax is

SWITCH variable
CASE state
… instructions …
DEFAULT
… instructions …
ENDSWITCH

Example

FOR I = 1 TO 10
SWITCH I
CASE 1
A = "ONE"
CASE 2
A = "TWO"
CASE 3
A = "THREE"
DEFAULT
A = "NEITHER 1 NOR 2 NOR 3"
ENDSWITCH
PRINT A