TAL Reference Manual

Statements
TAL Reference Manual526371-001
12-19
DO Statement
DO Statement
The DO statement is a posttest loop that repeatedly executes a statement until a
specified condition becomes true.
statement
is any statement described in this section.
condition
is either:
A conditional expression
An INT 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 loop continues to execute. If condition is true, the
statement following this DO statement executes.
Usage Considerations
If the condition is always false, the loop repeats until a statement in the DO loop
causes an exit.
A DO statement always executes at least once because the compiler tests
condition at
the end of the loop. Unless you have a special reason to use a DO statement, it is
safer to use the WHILE statement.
DO statement execution is shown in the
TAL Programmers Guide.
Examples of DO Statements
1. This DO statement loops through ARRAY_A, testing each the content of each
element until an alphabetic character occurs:
index := -1;
DO index := index + 1 UNTIL $ALPHA (array_a[index]);
DO
UNTIL
condition
statement
VST1212.vsd