while
- Last UpdatedMay 02, 2023
- 2 minute read
The while statement can create loops inside commands.
Loops can be very powerful for reducing script length, but also a bit dangerous if badly handled. Each command execution take place in a single frame, so an infinite or too long loop could cause application slow down.
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Code example
This is a code example for the while statement.
<command name="updateFlow"> <local name="idx" type="sint" value="0"/>
<while condition="@%idx%@<10">
<!-- ... -->
<setlocal name="idx" value="#@%idx%@+1#" />
</while>
</command>
Fields
These are the fields for while statement.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
condition |
sstring |
Optional |
No default value |
Used to evaluate loop execution. |