pTAL Reference Manual (H06.08+)

Statements
HP pTAL Reference Manual523746-006
12-16
Unlabeled CASE
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.
If you omit the OTHERWISE clause and selector is out of range (negative or
greater than n), a divide-by-zero instruction trap occurs.
Example 12-11. Unlabeled CASE Statement
INT(32) i;
CASE i OF
BEGIN
...
END;
CASE i OF
BEGIN
0-> ...
1-> ...
END;