TAL Reference Manual
Statements
TAL Reference Manual—526371-001
12-40
WHILE Statement
LITERAL len = 100;
INT .array [0:len - 1];
INT i;
FOR i := 0 TO len - 1 DO
array[i] := array[i] + 5; !Standard FOR loop
USE x; !Optimized FOR loop uses
FOR x := 0 to len - 1 DO ! an index register
array[x] := array[x] + 5;
DROP x; !Release the register
WHILE Statement
The WHILE statement is a pretest loop that repeatedly executes a statement while a
specified condition is true.
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.
statement
is any TAL statement.
Usage Considerations
The WHILE statement tests the condition before each iteration of the loop. If the
condition is false before the first iteration, the loop never executes. If the condition is
always true, the loop executes indefinitely unless a statement in the loop causes an
exit.
WHILE statement execution is shown in the
TAL Programmer’s Guide.
condition
WHILE
DO
statement
VST1223.vsd