Difference between revisions of "Break"
From Scriptwiki
m (added category) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | Breaks out of a while loop. | |
+ | /break | ||
+ | ==Example== | ||
+ | [[var]] %i = 1 | ||
+ | [[while]] (1) { | ||
+ | [[inc]] %i | ||
+ | [[if]] (%i == 12) { break } | ||
+ | } | ||
+ | [[echo]] Break at %i | ||
+ | The above script would break out of the while loop when %i reached 12. If the script did not have a break command, it would turn into an infinite loop as the statement ''1'' will always be true. | ||
+ | ==See Also== | ||
+ | * [[Continue|/continue]] | ||
+ | [[Category:Commands]] |
Latest revision as of 00:38, 7 April 2008
Breaks out of a while loop.
/break
Example
var %i = 1 while (1) { inc %i if (%i == 12) { break } } echo Break at %i
The above script would break out of the while loop when %i reached 12. If the script did not have a break command, it would turn into an infinite loop as the statement 1 will always be true.