pTAL Reference Manual (H06.03+)

Statements
HP pTAL Reference Manual523746-005
12-12
CASE
CASE
The CASE statement executes a choice of statements based on a selector value.
Normally, you use labeled CASE statements. Labeled CASE statements are described
first, followed by unlabeled CASE statements.
If a case index does not match any alternative, an instruction trap occurs.
Topics:
Empty CASE on page 12-12
Labeled CASE on page 12-13
Unlabeled CASE on page 12-15
Empty CASE
pTAL does not allow empty CASE statements. A CASE statement include at least one
alternative, even if there are no statements specified for that alternative.
Example 12-7. CALL Statement
PROC p (a, b, c);
INT(32) a;
REAL b;
REAL(64) c;
BEGIN
END;
PROC q;
BEGIN
CALL p(1.0E0, ! ERROR: Cannot pass REAL to INT(32)
1D, ! ERROR: Cannot pass INT(32) to REAL
1F); ! ERROR: Cannot pass FIXED to REAL(64)
END;
Example 12-8. Empty CASE Statement
CASE i OF
BEGIN ! In this unlabeled CASE statement,
; ! the semicolon creates an alternative
END;