TAL Reference Manual

Statements
TAL Reference Manual526371-001
12-22
FOR Statement
FOR Statement
The FOR statement is a pretest loop that repeatedly executes a statement while
incrementing or decrementing an index automatically. The loop terminates when the
index reaches a set value.
index
is a value that increments or decrements automatically until it reaches limit and
terminates the loop.
In a standard FOR loop, index is the identifier of an INT simple variable, array
element, simple pointer, or structure data item.
In an optimized FOR loop, index is the identifier of an index register you have
reserved by using the USE statement.
initial-value
is an INT arithmetic expression (such as 0) that initializes index.
TO
increments index each time the loop executes until index exceeds limit.
DOWNTO
decrements index each time the loop executes until index is less than limit.
limit
is an INT arithmetic expression that terminates the FOR looping.
step
is an INT arithmetic expression by which to increment or decrement index each
time the loop executes. The default value is 1.
statement
is any statement described in this section.
FOR index := initial-value TO limit
DOWNTO
DO
BY step statement
VST1214.vsd