variable
Description
The variable block is used to share one value between multiple places in a logic project. All instances of the block configured with the same variable name refer to the same shared value.
The block has one input and one output. It does not require the use of inputs labeled with the tag block. Every change received on the input of any variable instance is immediately forwarded to the output of all instances using the same variable name.
The variable value is not stored permanently. After the project is restarted, the variable returns to the null state and remains there until the first new value is received.
Configuration parameters
| Parameter name | Value |
|---|---|
name |
Required name of the variable shared by variable blocks. The name must be 1 to 25 characters long, may contain only ASCII letters, digits, and the _ character, and its first character must not be a digit. |
Input handling
The block accepts every change sent to its only input. All value types used in the project are supported, including:
null- boolean values
trueandfalse - integers
- floating-point numbers
- text
After receiving a new value, the block:
- stores it as the current value of the variable specified by the
nameparameter - forwards the same change to the output of all
variableblocks using the same variable name - updates the description shown below the block
The block does not require any tag inputs and does not impose any restrictions on the type of the transmitted value.
Block outputs
The block has one output. Every new value written to the shared variable with the given name appears on the output, regardless of which variable instance introduced it.
The description shown below the block displays:
- the number of active
variableblock instances using the same variable name - the current variable value in text form
Example descriptions:
1: nullmeans there is one instance of this variable and no stored value3: truemeans there are three instances of the same variable and the current boolean value istrue2: 21.5°Cmeans there are two instances of the same variable and the current numeric value is21.5°C
Errors returned by the block
The block can show the following error messages:
| Error code | Error description |
|---|---|
Variable name configuration error. |
The name parameter is missing in the configuration, is empty, or is not a text value. |
Invalid variable name. |
The variable name does not meet the requirements: its length is outside the 1-25 range, it contains forbidden characters, or it starts with a digit. |
Usage examples
- If two
variableblocks havename = living_room_mode, entering the valuetrueon the input of the first one causes the valuetrueto appear on the output of both blocks. - If one
variableblock namedtarget_tempreceives the value21.5, every othervariableblock namedtarget_tempimmediately starts providing the same value. - If a
variableblock namedscene_namereceives the textevening, the description below all blocks using this variable shows a value containingevening. - After the project is restarted, the value of the
alarm_statevariable is not preserved. Until a new value is written, the block description indicates thenullstate.