pTAL Reference Manual (H06.08+)

Statements
HP pTAL Reference Manual523746-006
12-18
DO-UNTIL
condition
is either:
A conditional expression
An INT, INT(32), or FIXED arithmetic expression. If the result of the arithmetic
expression is not 0, condition is true. If the result is 0, condition is false.
If condition is false, the DO-UNTIL statement continues to execute. If
condition is true, the statement following the DO-UNTIL statement executes.
A DO-UNTIL statement always executes at least once (unlike the WHILE on
page 12-45).
In Example 12-14 on page 12-18, the DO-UNTIL statement loops through array_a,
testing the content of each element until an alphabetic character occurs.
In Example 12-15 on page 12-18, the DO-UNTIL statement loops through array_a,
assigning a 0 to each element until all the elements contain a 0.
The conditional expression cannot reference hardware indicators (<, <=, =, <>, >, >=,
'<', '<=', '=', '<>', '>', '>=', $OVERFLOW, and $CARRY). Only IF statements can test
hardware indicators. For more information, see Section 13, Hardware Indicators.
To use a hardware indicators value to control a DO-UNTIL loop, save the hardware
indicators value and either test the saved value (as in Example 12-16 on page 12-19)
or execute an explicit GOTO statement to exit the loop (as in Example 12-17 on
page 12-19). Hardware indicators cannot appear in the conditional expression of a DO-
UNTIL statement.
Example 12-14. DO-UNTIL Statement
index := -1;
DO index := index + 1 UNTIL $ALPHA (array_a[index]);
Example 12-15. DO-UNTIL Statement
LITERAL limit = 9;
INT index := 0;
STRING .array_a[0:limit];y
DO
BEGIN ! Compound statement to execute in
array_a[index] := 0; ! DO loop
index := index + 1;
END
UNTIL index > limit; ! Condition for ending loop