SWITCH – CASE – BREAK – 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"
BREAK
CASE 2
A = "TWO"
BREAK
CASE 3
A = "THREE"
BREAK
DEFAULT
A = "NEITHER 1 NOR 2 NOR 3"
ENDSWITCH
PRINT A