Difference between revisions of "For"

From Wiki
Jump to: navigation, search
Line 1: Line 1:
__NOTOC__
+
{{command header|Flow Control}}
== For ==
+
{{body|for {variable} {start} {end} { }|The for command controls a loop that iterates a variable over a range of numbers. Both positive and negative iterations are legal.
'''Flow Control'''
+
====Synopsis====
+
  
<pre>for {variable} {start} {end}
+
The variable is assigned the starting number to begin with. After each iteration it either increments or decrements the variable, until it reaches the ending number.}}
{
+
  ...
+
}</pre>
+
 
+
====Description====
+
  
The for command controls a loop that iterates a variable over a range of numbers. Both positive and negative iterations are legal.
 
  
The variable is assigned the starting number to begin with. After each iteration it either increments or decrements the variable, until it reaches the ending number.
+
{{note|In EasyUO 1.4, you ''must'' use brackets, even if there is only a single line of code in a for loop. In EasyUO 1.5 however, brackets are optional when the for loop is only a single line of code.}}
  
In EasyUO 1.4, you ''must'' use brackets, even if there is only a single line of code in a for loop. In EasyUO 1.5 however, brackets are optional if the for loop is only a single line of code.
 
  
 
====Example====
 
====Example====
Line 26: Line 17:
 
halt</pre>
 
halt</pre>
  
=== See Also ===
+
{{footer}}
{|
+
| width=200px | [[while]] || width=200px | [[repeat..until]] || width=200px | [[continue]] || width=200px | [[break]]
+
|}
+
----
+
{|
+
| Width=200px | [[Main_Page]] || Width=200px | [[Documentation]] || Width=200px | [[Documentation#Flow_Control|Flow Control]]
+
|}
+

Revision as of 09:41, 27 August 2005

Synopsis

for {variable} {start} {end} { }

Description

The for command controls a loop that iterates a variable over a range of numbers. Both positive and negative iterations are legal.

The variable is assigned the starting number to begin with. After each iteration it either increments or decrements the variable, until it reaches the ending number.


Note: In EasyUO 1.4, you must use brackets, even if there is only a single line of code in a for loop. In EasyUO 1.5 however, brackets are optional when the for loop is only a single line of code.


Example

for %i 1 20
{
	msg %i $
	wait 10
}
halt

See also

Main Page Documentation