Difference between revisions of "For"
From Wiki
(removed TOC, fixed description, added to see also.) |
|||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{command header|Flow Control}} | |
− | + | {{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. | |
− | + | 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== | |
− | + | ||
− | + | ||
<pre>for %i 1 20 | <pre>for %i 1 20 | ||
Line 21: | Line 14: | ||
msg %i $ | msg %i $ | ||
wait 10 | wait 10 | ||
− | }</pre> | + | } |
+ | halt</pre> | ||
− | == | + | == Related Commands == |
− | {| | + | {| style="background:gainsboro; color:black; border: 2px #aaa solid;" |
− | + | | Width=250px align=center | [[Continue]] | |
− | + | ||
− | + | ||
− | + | ||
− | | Width= | + | |
|} | |} | ||
+ | =See Also= | ||
+ | {{Flow Control}} |
Latest revision as of 16:58, 5 September 2007
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
Related Commands
Continue |
See Also
Flow Control
- Flow control commands allow scripts to make decisions based on the evaluation of boolean expressions.
break | Jumps to first statement outside of loop |
call | Transfers execution to another script file |
continue | Jumps execution of a loop to next iteration |
exit | Exits a called script |
for | Creates a counting loop |
gosub | Transfers execution to the matching sub |
goto | Jumps to another part of the script given by a label |
halt | Stops the script |
if | Executes code based on the evaluation of an expression |
pause | Temporarily stops the execution of the current script |
repeat..until | Creates a loop that checks condition after execution |
return | Returns from a sub |
stop | Ends the script |
while | Creates a loop that checks condition before execution |