Update¶
Name | - | Description | Default | Type |
---|---|---|---|---|
<input> |
Input is the new value of the variable being updated. | Any |
||
<output> |
The input to this shard is passed through as its output. | Any |
||
Name |
The name of the variable. | "" |
String &Any |
|
Key |
The key of the value to read from the table (parameter applicable only if the target variable is a table). | None |
String &String |
|
Global |
If the variable is available to all of the wires in the same mesh. | false |
Bool |
Modifies the value of an existing mutable variable.
Details¶
Update
modifies the value of an existing mutable variable.
The name of the variable comes from the :Name
parameter and the update value comes from the input.
Update
overwrites string, numeric, and sequence variables with the new value (coming from input). However, for sequences, it cannot update a sequence at the level of elements (i.e., add elements, remove elements, change element order, etc.), so it overwrites the whole sequence with whatever you've passed in the input field.
Also, for an existing table, Update
can only change the existing keys' values. It cannot add new key-value pairs to the table (do that with Set
). To update existing key-values in a table you need to pass the key in the :Key
parameter.
Since 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), both parameters :Global
and :Name
are used in combination to identify the correct variable to update.
The input to this shard is the update value to be applied to the mutable variables and is also passed through as this shard's output.
Note
Update
has an alias >
. Its an alias for Update
with the defaults: (Update ...)
. See the code examples at the end to understand how this alias is 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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
[info] [shards/General/Update/Update.edn] .svar: Hello
[info] [shards/General/Update/Update.edn] modified .svar: World
[info] [shards/General/Update/Update.edn] .nvar: 100
[info] [shards/General/Update/Update.edn] modified .nvar: 200
[info] [shards/General/Update/Update.edn] .sequence: [100]
[info] [shards/General/Update/Update.edn] .table1: {key1: [a b]}
[info] [shards/General/Update/Update.edn] .table1: {key1: [def]}
[info] [shards/General/Update/Update.edn] .svarA: Hello
[info] [shards/General/Update/Update.edn] modified .svar: World
[info] [shards/General/Update/Update.edn] {key1: [a b]}
[info] [shards/General/Update/Update.edn] {key1: [c d]}
[info] [shards/General/Update/Update.edn] {key1: [X]}
[info] [shards/General/Update/Update.edn] {key1: [Y]}