CASE expr OF { "|" case ... } [ ELSE statements ] END where case = { label "," ... } "=>" statements label = const-expr [ ".." const-expr ]
The case statement is a specialization of the IF/THEN/ELSIF statement that allows discrimination among a set of possible values of some ordinal expression expr. If a case is encountered that is not handled by one of the arms of the case statement, the ELSE arm is taken; if no ELSE arm is present in this situation, a checked run-time error occurs.
The compiler will generate a warning if no ELSE arm appears and not all cases are covered. This can be ignored at risk of a possible runtime error, or an empty ELSE arm can be inserted to pacify the compiler and runtime system.
CASE IO.GetChar() OF | 'a'..'z' => IO.Put("Lowercase"); | 'A'..'Z' => IO.Put("Uppercase"); | '0'..'9' => IO.Put("Digit"); | '!', '.', ':', ';', '?' => IO.Put("Punctuation"); ELSE IO.Put("Other") END