Difference between revisions of "Repeat..until"

From Wiki
Jump to: navigation, search
Line 1: Line 1:
__NOTOC__
+
{{command header|Flow Control}}
== Repeat..until ==
+
{{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 differe's 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.}}
'''Flow Control'''
+
=== 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, unlike [[while]] loops, [[repeat..until]] loops will always execute the code within the loop at least once.
+
  
 
==== Example ====
 
==== Example ====
Line 22: Line 15:
 
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.
  
=== See Also ===
+
{{footer}}
{|
+
| width=200px | [[while]] || width=200px | [[for]] || width=200px | [[continue]] || width=200px | [[break]]
+
|}
+
----
+
{|
+
| Width=200px | [[Main_Page]] || Width=200px | [[Documentation]] || Width=200px | [[Documentation#Flow_Control|Flow Control]]
+
|}
+

Revision as of 09:34, 27 August 2005

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 differe's 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.

See also

Main Page Documentation