pTAL Reference Manual (H06.08+)
Statements
HP pTAL Reference Manual—523746-006
12-21
Nested
limit
is an arithmetic expression that terminates the loop. If index is INT, initial-
value is INT. If index is INT(32), initial-value is INT(32).
step
is an arithmetic expression by which to increment or decrement index each time
the loop executes. If index is INT, then step is INT; otherwise, index is
INT(32). The default is 1.
statement
is any statement described in this section.
The FOR statement tests index at the beginning of each iteration of the loop. If
index exceeds limit on the first test, the loop never executes.
Topics:
•
Nested on page 12-21
•
Standard on page 12-21
•
Optimized on page 12-22
Nested
You can nest FOR statements to any level.
The nested FOR statement in Example 12-18 on page 12-21 uses multiples as a
two-dimensional array. It fills the first row with multiples of 1, the next row with multiples
of 2, and so on.
Standard
For index, standard FOR statements specify an INT or INT(32) variable. Standard
FOR statements execute as follows:
•
When the looping terminates, index is greater than limit if:
°
The step value is 1.
°
You use the TO keyword (not DOWNTO).
°
The limit value (not a GOTO statement) terminates the looping.
Example 12-18. Nested FOR Statement
INT .multiples[0:10*10-1];
INT row;
INT column;
FOR row := 0 TO 9 DO
FOR column := 0 TO 9 DO
multiples [row * 10 + column] := column * (row + 1);










