Difference between revisions of "Repeat..until"
From Wiki
(→Description: fixed for clarity.) |
|||
(11 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{command header|Flow Control}} | |
− | + | {{body|repeat { } until ( expression )|The ''repeat..until'' control structure executes the code block between the statements, and then evaluates the expression. This will make it so that [[repeat..until]] loops will always execute the code within the loop at least once. This command differs from the [[while]] command because the expression is evaluated prior to the code inside the code block, where [[while]] evaluates the expression after executing it's code block.}} | |
− | + | ||
− | + | ||
− | + | ||
− | until | + | |
− | + | ||
− | The repeat..until control structure executes the code block between the statements, and then evaluates the expression. | + | |
− | + | ||
==== Example ==== | ==== Example ==== | ||
<pre> | <pre> | ||
set %str Hello , #spc , World | set %str Hello , #spc , World | ||
− | repeat | + | repeat |
+ | { | ||
set %str %str , ! | set %str %str , ! | ||
− | str len %str | + | str len %str |
+ | } | ||
until #strres >= 30 | until #strres >= 30 | ||
display ok %str | display ok %str | ||
Line 22: | Line 17: | ||
The example above illustrates the difference between a repeat..until loop and a while loop. the exclamation point will always be concatinated to the end of the %str variable, and str len will be executed once before the test for #strRes >= 30 is first evaluated. | The example above illustrates the difference between a repeat..until loop and a while loop. the exclamation point will always be concatinated to the end of the %str variable, and str len will be executed once before the test for #strRes >= 30 is first evaluated. | ||
− | + | {{1.5only}} | |
− | { | + | =See Also= |
− | + | {{Flow Control}} | |
− | + | ||
− | + | ||
− | { | + | |
− | + | ||
− | + |
Latest revision as of 16:59, 5 September 2007
Synopsis
repeat { } until ( expression )
Description
The repeat..until control structure executes the code block between the statements, and then evaluates the expression. This will make it so that repeat..until loops will always execute the code within the loop at least once. This command differs from the while command because the expression is evaluated prior to the code inside the code block, where while evaluates the expression after executing it's code block.
Example
set %str Hello , #spc , World repeat { set %str %str , ! str len %str } until #strres >= 30 display ok %str halt
The example above illustrates the difference between a repeat..until loop and a while loop. the exclamation point will always be concatinated to the end of the %str variable, and str len will be executed once before the test for #strRes >= 30 is first evaluated.
Note: | Only available in EasyUO 1.5+ |
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 |