For
The For statement is used to repeatedly execute a statement a fixed number of times. The number of repetitions is controlled by a variable that is incremented by one for each repetition until it matches the final-value. The syntax of a For statement is:
For {control-variable} From {initial-value} To {final-value}
{statement 1}
{statement 2}
…
{statement n}
Loop
Where:
-
{control-variable} is the integer variable that is used to control the number of repetitions.
-
{initial-value} is the initial setting for the control variable the first time the
Forstatement is executed. The initial value can be a constant, variable, or expression of type Integer. -
{final-value} is the highest value that the control variable will be incremented to during execution of the
Forstatement. When the control variable exceeds the final value, theForstatement will stop looping. The final value can be a constant, variable, or expression of type Integer.
The statements contained by the For statement are executed once for every incremental value of the control variable in the range from initial value to final value.
The Loop command marks the end of the block of statements that are contained by the For statement.
Here are some example For statements:
For iCount From 1 To 255
Move (sASCIIchars + Character(iCount)) To sASCIIchars
Loop
For iX From ixStart To ixStop
For iY From iyStart To iyStop
Move (GraphValue(iX, iY)) to iValue
Showln "Value at " iX "," iY " = " iValue
Loop
Loop