Difference between revisions of "Break"

From Wiki
Jump to: navigation, search
(Description: usefull for more than just while loops. also, please dont link to the current page, use bold for emphasis.)
Line 5: Line 5:
 
Break
 
Break
 
=== Description ===
 
=== Description ===
[[break]] can be used to jump out from [[while]] loop
+
[[break]] can be used to immediately exit any loop structure.
  
 
==== Example ====
 
==== Example ====
Line 23: Line 23:
 
</pre>
 
</pre>
  
%Test will hold the value of 7, notice how we [[break]] out from the loop when %Test is 7.
+
%Test will hold the value of 7, notice how we break out from the loop when %Test is 7.
  
 
=== See Also ===
 
=== See Also ===

Revision as of 16:19, 24 August 2005

Break

Flow Control

Synopsis

Break

Description

break can be used to immediately exit any loop structure.

Example

set %Test 1

while %Test < 10
{
;Code between these brackets, gets executed, while %Test is smaller than 10
;When its 10, it wont jump back to first bracket.
if %Test = 7
   break
set %Test %Test + 1
}
display ok %Test $
halt

%Test will hold the value of 7, notice how we break out from the loop when %Test is 7.

See Also

while

Main_Page Documentation Flow Control