for
- Last UpdatedAug 21, 2023
- 2 minute read
The for 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 takes place in a single frame, so an infinite or too long loop could cause the application to slow down.
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable Hololens 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 for statement.
<command name="updateFlow">
<for name="idx" value="0" condition="@%idx%@<10" increment="#@%idx%@+1#">
<log text="idx @%idx%@"/>
</for>
</command>
Fields
These are the fields for the for statement.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
condition |
sstring |
Optional |
Not set |
Used to evaluate loop execution. |
|
name |
sstring |
Optional |
Not set |
The variable to increment at each loop. |
|
value |
sint |
Mandatory |
Not set |
Starting value of the name variable. |
|
increment |
sstring |
Mandatory |
Not set |
Assigned value to the name variable after each loop. |