Modifying the bounds/step of a FOR loop inside the loop is forbidden
This compiler error will occur if, within a for loop, you try to modify the value of any of the variables that are used to calculate the expressions for the start point, end point and step value of the loop.
for nCtr = nStart to nEnd step nInc
nStart = nCtr + 2 // NO !!!
nEnd = nCtr + nStart // NO !!!
nInc = nTokenDayValue div 2 // NO !!!
The reasons behind this restriction are :
•Shifting the parameters of a for instruction makes it hard to follow for human readers, including the person writing the Macro, and can easily lead to bugs.
•The compiled code is optimized to take advantage of the fact that all the elements of a for loop remain constant, during the loop. Changing this would make for slower execution of loops at run-time.
•Allowing the end point or step value to change could lead to an infinite loop (as would happen in the above example).
Note that using the counter variable (which changes automatically at the end of each loop iteration) in any of the expressions used to calculate the start point, end point and step value of the loop, is also forbidden.
If you feel you must absolutely change the value of any the for loop variables, this is a sign that you should be using a while loop instead of a for loop. For a discussion on which of the loops to use, see Looping Instructions.