pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Example 150 Unlabeled CASE Statement
INT(32) i;
CASE i OF
BEGIN
...
END;
CASE i OF
BEGIN
0-> ...
1-> ...
END;
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 151 Unlabeled CASE Statement
INT selector;
INT var0;
INT var1;
CASE selector OF
BEGIN
var0 := 0; ! Executes if selector=0
var1 := 1; ! Executes if selector=1
OTHERWISE
CALL error_handler; ! Executes if selector is not 0 or 1
END;
Example 152 (page 210) selectively moves one of several messages into an array.
Example 152 Unlabeled CASE Statement Assigning Text to Array
PROC msg_handler (selector);
INT selector;
BEGIN
LITERAL len = 80; ! Length of array
STRING .a_array[0:len - 1]; ! Destination array
CASE selector OF
BEGIN ! Move statements
!0! a_array ':=' "Training Program";
!1! a_array ':=' "End of Program";
!2! a_array ':=' "Input Error";
!3! a_array ':=' "Home Terminal Now Open";
OTHERWISE
a_array ':=' "Bad Message Number";
END; ! End of CASE statement
END; ! End of procedure
DO-UNTIL
The DO-UNTIL statement is a posttest loop that repeatedly executes a statement until a specified
condition becomes true.
statement
is any statement described in this section.
210 Statements