pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-15
Unlabeled CASE
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.
Example 12-10. Labeled CASE Statement
INT location;
LITERAL bay_area, los_angeles, hawaii, elsewhere;
PROC area_proc (area_code);
INT area_code; ! Declare selector as
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
CASE selector OF
BEGIN
statement-1
;
statement-2
;
END
OTHERWISE
VST040.vsd