Get¶
Name | - | Description | Default | Type |
---|---|---|---|---|
<input> |
Any input is ignored. | |||
<output> |
The output is the value read from the variable. | 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 |
|
Default |
The default value to use to infer types and output if the variable is not set, key is not there and/or type mismatches. | None |
Any |
Reads the value of the variable passed to it.
Details¶
Get
is used read the value of an existing variable. All sorts of variables that can be created by Set
, can be read by Get
.
The :Name
parameter should contain the name of the variable that's being read. If the variable is a string/numeric variable or a sequence it will be read directly. But for a table to be read its key should be passed in the parameter :Key
. This will allow Get
to access the particular key in the table and read it's value.
The :Default
parameter specifies a value to return in case the variable being read doesn't yeild a valid value, or the sequence is malformed, or the required key is missing from the table, etc. This allows the program to continue processing even if some expected data is missing.
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 read.
Any input to this shard is ignored and its output contains the value of the variable read by Get
.
Note
Get
has an alias ??
. This symbol represents the logical operator OR
. Hence, ??
functions as an alias for Get
with a default value. For example, .var1 ?? 40
means .var1 or 40
and this is effectively an alias for (Get .var1 :Default 40)
. 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 |
|
[info] Set - Warning: setting an already exposed variable "str", use Update to avoid this warning.
[info] [shards/General/Get/Get.edn] gotten value: Hello
[info] [shards/General/Get/Get.edn] gotten value: 100
[info] [shards/General/Get/Get.edn] [10 20 30]
[warning] Get found a variable but it's using the default value because the type found did not match with the default type.
[info] [shards/General/Get/Get.edn] Void
[info] [shards/General/Get/Get.edn] [a b]
[info] [shards/General/Get/Get.edn] Key missing
[info] [shards/General/Get/Get.edn] Key still missing
[info] [shards/General/Get/Get.edn] Local
[info] [shards/General/Get/Get.edn] Global