Ref¶
| 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 read from 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 |
Creates an immutable reference variable. Once created this variable cannot be changed.
Details¶
The name of the variable comes from the Name parameter and the constant value comes from the input. The type of input controls the type of variable that will be created: numeric input creates numeric variable, string input creates string variable, and sequence input would create a sequence variable.
To create a table variable, along with the input, you also have to pass the key in the Key parameter. In this case the input (whatever it may be - numeric, string, sequence) 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).
The input to this shard is used as the value for the new variable and is also passed through as this shard's output.
Note
Ref has two aliases: = and &>. Both are aliases for (Ref ... :Global false). See the code examples at the end to understand how these aliases are used.
Examples¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
[info] [sample-wire] .svar: Hello
[info] [sample-wire] .nvar: 100
[info] [sample-wire] .seq: [10 20]
[info] [sample-wire] .table: {key1: [a b]}
[info] [sample-wire] .svarA: World