Syntax
SWITCH exp
[CASE literal
statements...]
[OTHERWISE
statements...]
ENDSWITCHArguments
exp is the selector. Each CASE label is a unique integer, string or NIL literal. An integer label may have a leading sign and must lie between -9007199254740991 and 9007199254740991.
Description
Execution starts at the matching CASE and proceeds through following blocks until EXIT, RETURN or the end of SWITCH. This includes OTHERWISE when execution reaches it from a CASE. If no label matches, execution starts at OTHERWISE if present.
Example
PROCEDURE Main()
LOCAL cEvent
LOCAL nBalance := 0
FOR EACH cEvent IN { "deposit", "refund", "sale", "audit", "hold" }
SWITCH cEvent
CASE "deposit"
CASE "refund"
// Both labels enter the same credit branch.
nBalance += 10
EXIT
CASE "sale"
nBalance -= 5
EXIT
CASE "audit"
QOut( "Audit balance", nBalance )
EXIT
OTHERWISE
QOut( "Unknown event", cEvent )
ENDSWITCH
NEXT
QOut( "Closing balance", nBalance )
RETURNOutput