===== For / Next (Statement) =====
==== Format ====
**for** [[variables|variable]] = [[numericexpressions|start_expression]] **to** [[numericexpressions|stop_expression]] [ **step** [[numericexpressions|step_expression]] ] \\
(tab)[[programsyntax|statement(s)]]\\
**next** [[variables|variable]]
==== Description ====
The FOR and NEXT commands are used in conjunction to execute a command or group of commands a specified number of times. When the FOR command is first encountered, the variable is set to [[numericexpressions|start_expression]].\\
After each NEXT command, variable is incremented by 1 (the default), or by [[numericexpressions|step_expression]] if the optional STEP is used, until the variable is greater than [[numericexpressions|stop_expression]] for positive step values, or less than [[numericexpressions|stop_expression]] for negative step values.
==== Example ====
for i = 1 to 5
print i
next i
print "after the for " + i
for k = 5 to 1 step -1
? k
next
displays
1
2
3
4
5
after the for 6
5
4
3
2
1
==== See Also ====
{{page>en:start#Program Control&noheader}}
==== History ====
|2.0.0.0|Variable in Next statement is now optional|