For Statement

A for statement sets up a special loop with a controlling loop variable that runs from an initial value up or down to some final value. e.g.
    for i=1 to 10 do
        ? i   -- ? is a short form for print()
    end for
    for i=10 to 20 by 3 do
        for j=20 to 10 by -2 do  -- counting down
            ? {i, j}
        end for
    end for
If the loop variable has already been declared it persists after the loop and can be inspected for a termination value, otherwise it is declared automatically and only exists until the end of the loop. In the latter case, outside of the loop the variable has no value and is not even declared. The compiler does not allow assignment to a loop variable. The initial value, loop limit and increment must all be integers. If no increment is specified then +1 is assumed. The limit and increment values are established when the loop is entered, and are not affected by anything that happens during the execution of the loop. See also scope of the loop variable.

An "illegal construct" error occurs if the end for statement is immediately preceded by an unconditional exit - use an if construct instead.

Compatibility Note: RDS Eu and OpenEuphoria allow floating point for loops, which Phix does not.
However, quite often they do not work as anticipated (in Eu/OE), for example:
    NB: this is NOT supported in Phix, but showing what RDS Eu/OpenEuphoria both do:
    for x=1.7 to 1.9 by 0.1 do ?x end for   -- prints 1.7,1.8
    for x=9.7 to 9.9 by 0.1 do ?x end for   -- prints 9.7,9.8,9.9
I have not analysed why that specific case happens, and have no desire to replicate it.
Besides, it is trivial to use a predictable integer loop variable alongside a manually incremented/decremented atom to achieve the required effect, and that is certainly easier than at least one technique to ensure the desired number of iterations occur that I have seen more than once in Eu/OE: adjusting limit by a "step/2 fudge factor".

See also: Floats Are Not Exact