next up previous contents index
Next: The Goto statement Up: Statements controlling program flow. Previous: The Case statement

The For..to/downto..do statement

Free Pascal supports the For loop construction. The prototypes are:

For Counter:=Lowerbound to Upperbound Do Statement;

or 

For Counter:=Upperbound downto Lowerbound Do Statement;
Statement can be a compound statement. In the first case, if Lowerbound is larger than Upperbound then Statement will never be executed. Counter must be an ordinal type, no other types can be used as counters in a loop.

Remark: Contrary to ANSI pascal specifications, Free Pascal first initializes the counter variable, and only then calculates the upper bound.



Michael Van Canneyt
Thu Sep 10 14:02:43 CEST 1998