copy
- Last UpdatedJan 18, 2024
- 2 minute read
The copy statement assigns value to any node field or local variable from another field or local variable. It is used inside a Command node or a Coroutine node.
Platform support
This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P 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 set statement operating both on a field and a local.
<Var name="varjson" type="sjson">
{
"object":
{
"value": "a string value"
},
"array": [ "value", ["arrayValue"], {"objectValue": "object value"}],
"string": "a string",
"integer": 1,
"boolean": true,
"float": 1.5
}
</Var>
<command name="copycommand">
<local name="firstlocal" type="sstring" />
<copy name="firstlocal" field="varjson.value"/>
<log text="Local copied from var: [@%firstlocal%]" />
</command>
Position
The copy statement can be used only inside a Command node or a Coroutine node.
Fields
These are the fields for copy statement.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
condition |
sstring |
Optional |
Not set |
Applies a condition to the function execution. |
|
name |
sstring |
Mandatory |
Not set |
Defines the node field or local to be assigned. Fields use the nodeName.fieldName syntax, while locals are pointed at by using their name without specifying a field. |
|
field |
sstring |
Mandatory |
Not set |
The field to be assigned to the target name field. The value will not be resolved and will be copied as is. |