pTAL Reference Manual (H06.08+)
Statements
HP pTAL Reference Manual—523746-006
12-14
Labeled CASE
upper-case-label
is the largest value in an inclusive range of signed INT constants or LITERALs.
statement-1
is any statement described in this section.
OTHERWISE
specifies an optional sequence of statements to execute if selector does not
select any case-alternative. If no OTHERWISE clause is present and
selector does not match a case-alternative, a run-time error occurs.
Always include an OTHERWISE clause, even if it contains no statements.
statement-2
is any statement described in this section.
A CASE statement must have at least one alternative.
If you omit the OTHERWISE clause and selector is out of range (negative or
greater than n), the a divide-by-zero instruction trap occurs.
A CASE index matches an alternative identified by the keyword OTHERWISE if and
only if the case index does not match any other alternative and OTHERWISE is an
alternative.
Example 12-9. Labeled CASE Statement
LITERAL apple, orange, pear, peach, prune;
INT i;
i := peach; ! Set index value
CASE i OF ! Execute CASE
BEGIN
apple -> CALL p1;
orange -> CALL p2;
prune -> CALL p3;
OTHERWISE -> CALL p4; ! Execute this alternative
END;










