(Contents)(Previous)(Next)

The FOR Statement

The FOR statement executes statements in a loop. The number of times the loop is run through is determined by an initial and a final value. Before the processing loop is executed for the first time, the control variable specified behind the keyword FOR obtains the value specified behind ':=' as initial value. Each time the loop is run through, the value of the control variable increases by 1. The processing loop is terminated as soon as the value of the control variable has reached the final value behind the keyword TO and the statements have been executed. After termination of the loop, the control variable has the final value.

The processing loop is not executed if the initial value is greater than the final value.

When DOWNTO is used instead of TO, the initial value must not be smaller than the final value in order that the processing loop is executed. Correspondingly, the control variable is decreased by 1 for each loop.

Examples:

Syntax:


(Contents)(Previous)(Next)