User Tools

Site Tools


en:for

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:for [2016/08/07 21:00]
admin
en:for [2020/04/26 22:26] (current)
admin
Line 1: Line 1:
 ===== For / Next (Statement) ===== ===== For / Next (Statement) =====
 ==== Format ==== ==== Format ====
-**for** [[variables|variable]] =  //start_expr// **to** //stop_expr// [ **step** //step_expr// ] \\ +**for** [[variables|variable]] =  [[numericexpressions|start_expression]] **to** [[numericexpressions|stop_expression]] [ **step** [[numericexpressions|step_expression]] ] \\ 
-(tab)//statement(s)//\\+(tab)[[programsyntax|statement(s)]]\\
 **next** [[variables|variable]] **next** [[variables|variable]]
  
 ==== Description ==== ==== 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 //start_expr//.\\ +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 //step_expr// if the optional STEP is used, until the variable is greater than or equal to //stop_expr// for positive step values, or less than or equal to //stop_expr// for negative step values.+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 ==== 
 +<code> 
 +for i = 1 to 5 
 + print i 
 +next i 
 + 
 +print "after the for " + i 
 + 
 +for k = 5 to 1 step -1 
 + ? k 
 +next 
 +</code> 
 +displays 
 +<code> 
 +
 +
 +
 +
 +
 +after the for 6 
 +
 +
 +
 +
 +
 +</code>
  
 ==== See Also ==== ==== See Also ====
 {{page>en:start#Program Control&noheader}} {{page>en:start#Program Control&noheader}}
 +
 +==== History ==== 
 +|2.0.0.0|Variable in Next statement is now optional|
en/for.1470625219.txt.gz · Last modified: 2020/02/28 10:46 (external edit)