Difference between revisions of "Continue"

From Wiki
Jump to: navigation, search
 
(Description: clarity, grammar, spelling)
Line 5: Line 5:
 
[[continue]]
 
[[continue]]
 
=== Description ===
 
=== Description ===
With [[continue]], you can continue to last line of any loop ( [[while]] and [[for]] ), so that it can start looping again. Ofcourse loop conditions must be valid in order to continue loop, otherwise it just jumps out from loop.
+
Continue stops execution of code inside of a loop. Control is returned at the point of the next evaluation.
  
 
==== Example ====
 
==== Example ====
Line 26: Line 26:
 
</pre>
 
</pre>
  
When random is something else than 5, the if sentence is true and therefor [[continue]] gets executed. It jumps over [[display]] and [[return]] commands and continues [[for]] loop if its not over yet ( if %cnt is NOT 10 .
+
When random is something other than 5, the if sentence is true and therefore continue is executed. It jumps over the [[display]] and [[return]] commands and continues the [[for]] loop with it's next iteration. In the case that the evaluation is false, execution proceeds to the statement following the loop structure.
  
 
=== See Also ===
 
=== See Also ===

Revision as of 16:46, 24 August 2005

Continue

Flow Control

Synopsis

continue

Description

Continue stops execution of code inside of a loop. Control is returned at the point of the next evaluation.

Example

gosub testrandom 
sub testrandom 
{ 
  for %cnt 1 10 
  { 
    if #random % 10 <> 5 
      continue 
    display ok Five has been found! 
    return 
  } 
  display ok Nothing could be found! 
  return 
} 
display ok HALT! 
halt

When random is something other than 5, the if sentence is true and therefore continue is executed. It jumps over the display and return commands and continues the for loop with it's next iteration. In the case that the evaluation is false, execution proceeds to the statement following the loop structure.

See Also

break while for

Main_Page Documentation Flow Control