Set¶
| Name | Mandatory | Description | Default | Type |
|---|---|---|---|---|
⬅️ Input |
The value to be set to the variable. | Any |
||
Output ➡️ |
The input value is passed through as the output. | Any |
||
Name |
No | The name of the variable. | `` | StringVar(Any) |
Key |
No | The key of the value to write in the table (parameter applicable only if the target variable is a table). | none |
Any |
Global |
No | If the variable is available to all of the wires in the same mesh. | false |
Bool |
TrackingMask |
No | If not 0, they variable will emit events when updated, according to the tracking mask, 8bits. | 0 |
Int |
Creates a mutable variable and assigns a value to it.
Details¶
If theKey parameter is specified, Set will create a table variable. The input becomes the value of the key that was passed in parameter Key.
The Global: parameter controls whether the created variables can be referenced across wires (:Global set to true) or only within the current wire (Global: set to false, default behaviour).
Though it will generate a warning Set can also be used to update existing variables (like adding a new key-value pair to an existing table, or updating the value of a key in an existing table).
Variables may be locally scoped (created with (Global: false); exists only for current wire) or globally scoped (created with (Global: true); exists for all wires of that mesh). Hence, in update mode (i.e. when you apply Set to an existing variable) the Global parameter is used in conjunction with the Name parameter to identify the correct variable to update.
Note
Set has an alias >=.
Examples¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
[info] Set - Warning: setting an already exposed variable "str", use Update to avoid this warning.
[info] Set - Warning: setting an already exposed variable "str", use Update to avoid this warning.
[info] Set - Warning: setting an already exposed variable "str", use Update to avoid this warning.
[info] [sample-wire] .svar: Hello
[info] [sample-wire] modified .svar: World
[info] [sample-wire] .nvar: 100
[info] [sample-wire] modified .nvar: 200
[info] [sample-wire] .sequence: [10 20 30]
[info] [sample-wire] .table: {key1: [a b]}
[info] [sample-wire] modified .table: {key1: [a b] key2: def}
[info] [sample-wire] .svarA: World
[info] [sample-wire] .nvarA: 100
[info] [sample-wire] Local
[info] [sample-wire] Global
[info] [sample-wire] LocalNew
[info] [sample-wire] GlobalNew