You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== while ==
Copy Code
The output would be:
Copy Code
The output would be:
While the condition is true, the code is executed. break and continue work inside a dowhile, but continuing more than once is pointless, since the loop isn't inherently keeping track of any counters anyways. Breaking multiple times still works however.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| while
|-
! scope="row" | Returns
| void
|-
! scope="row" | Usages
| condition, [code]
|-
! scope="row" | Throws
|
|-
! scope="row" | Since
| 3.3.1
|-
! scope="row" | Restricted
| No
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
while(condition, [code])=== Examples === ====Example 1==== Basic usage Given the following code:
assign(@i, 5)
while(@i > 0,
msg(@i)
@i--
)

1 {{function|assign}}(@i, 5)
2 {{keyword|while}}(@i > 0,
3 {{function|msg}}(@i)
4 @i--
5 )
5 4 3 2 1====Example 2==== With a break Given the following code:
assign(@i, 0)
while(true,
msg(@i)
@i++
if(@i > 5, break())
)

1 {{function|assign}}(@i, 0)
2 {{keyword|while}}({{keyword|true}},
3 {{function|msg}}(@i)
4 @i++
5 {{keyword|if}}(@i > 5, {{function|break}}())
6 )
0 1 2 3 4 5===See Also=== [[Loops|Learning Trail: Loops]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)