Step size of a FOR loop.
Syntax
for !i=a to b step n
[commands]
next
step may be used in a FOR loop to specify the size of the step in the looping variable. If no step is provided, for assumes a step of “+1”.
If a given step exceeds the end value b in the FOR loop specification, the contents of the loop will not be executed.
Examples
for !j=5 to 1 step -1
series x = nrnd*!j
next
repeatedly executes the commands in the loop with the control variable !J set to “5”, “4”, “3”, “2”, “1”.
for !j=0 to 10 step 3
series z = z/!j
next
Loops the commands with the control variable !J set to “0”, “3”, “6”, and “9”.
You should take care when using non-integer values for the stepsize since round-off error may yield unanticipated results. For example:
for !j=0 to 1 step .01
series w = !j
next
may stop before executing the loop for the value !J=1 due to round-off error.
Cross-references