return
- Last UpdatedMay 02, 2023
- 2 minute read
The return statement forces exit from command execution and sets the returnValue when required by the Command node or Coroutine node.
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 examples
These are code examples for the return statement.
This example shows Command node with no returnType set.
<!--command with no returnType set-->
<Command name="updateFlow">
<if condition="@pickResult.value.[0]@==1" >
<debug text="@pickResult.value.elementAt(1)@"/>
<setfield field="pickValue.value" value="[@fx_[@pickResult.value.elementAt(1)].getAlphaColor.execute([@pickResult.value.elementAt(9)],[@pickResult.value.elementAt(10)])]" />
<return />
</if>
<!-- the following code is not executed if the return is execute -->
<if condition="@pickResult.value.[0]@==2">
<!-- ... -->
</if>
</Command>
This example shows Command node with returnType set.
<!--command with returnType set -->
<Command name="doSum" args="a=sfloat,b=sfloat" returnType="sfloat" />
<local name="sum" type="sfloat" value="#[@%a%]+[@%b%]#" />
<return value="[@%sum%]" />
</Command>
Fields
These are the fields for return statement.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
condition |
sstring |
Optional |
No default value |
Applies a condition to the function execution. |
|
value |
Depends on command returnType |
Optional |
No default value |
If Command has a returnType set, all execution paths must return a value of the corresponding type. If returnType is set to void or not specified, this field should not be specified. |