Break: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Doomie (talk | contribs)
No edit summary
 
Daveoh (talk | contribs)
m added category
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
#Redirect [[While_loops]]
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 23:38, 6 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.

See Also