pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
BEGIN ! formal parameter
CASE area_code OF ! Selector is area_code
BEGIN
408, 415 ->
location := bay_area;
213, 818 ->
location := los_angeles;
808 ->
location := hawaii;
OTHERWISE ->
location := elsewhere;
END; ! End CASE statement
END; ! End area_proc
Unlabeled CASE
The unlabeled CASE statement executes a choice of statements, based on an inclusive range of
implicit selector values, from 0 through n, with one statement for each value.
selector
is an INT or INT (32) arithmetic expression that selects the statement to execute.
statement-1
is any statement described in this section. Include a statement-1 for each value in the
implicit selector range, from 0 through n. If a selector has no action, specify a null
statement (semicolon with no statement). If you include more than one statement-1 for a
value, you must use a compound statement.
OTHERWISE
indicates the statement to execute for any case outside the range of selector values. If the
OTHERWISE clause consists of a null statement, control passes to the statement following the
unlabeled CASE statement.
statement-2
is any statement described in this section. Include a statement-2 for each value in the
implicit selector range, from 0 through n. If a selector has no action, specify a null
statement (semicolon with no statement). If you include more than one statement-2 for a
value, you must use a compound statement.
The compiler numbers each statement in the BEGIN clause consecutively, starting with 0. If the
selector matches the compiler-assigned number of a statement, that statement is executed.
For example, if the selector is 0, the first statement executes; if the selector is 4, the
fifth statement executes. Conversely, if the selector does not match a compiler-assigned
number, the OTHERWISE statement, if any, executes.
The index of an unlabeled CASE statement and the selector of a labeled CASE statement can be
INT(32) expressions.
CASE 209