Variables – Dynamic Writing
The "Variables – Dynamic Writing" transfer object allows you to write variables whose names are not determined until runtime. Unlike with the Variable Transfer Object, you do not select the variable during project configuration; instead, you pass the variable name via an input pin.
The transfer object has two input pins:
| Pin | Direction | Description |
|---|---|---|
| VariableName | Input | Name of the variable to be written. An array of names is also possible; in this case, all specified variables are written. |
| Value | Input | The value or values to be written. |
Names and values are assigned as follows:
- One name and one value: The value is written to the variable.
- An array of names and an array of values of equal length: The values are assigned position-by-position.
- An array of names and a single value: All specified variables receive the same value.
- One name and multiple values: The variable receives all values as an array.
If the lengths of the name array and the value array differ, the transfer object triggers a transfer error.
After double-clicking the transfer object, configure the following properties:
| Property | Description |
|---|---|
| Scope | If “Global (across all flows)” is enabled, the variable is written to the global scope. Otherwise, it is written to the local scope of the respective flow. |
| Behavior | If “Create variable if not present” is enabled, an unknown variable is automatically created as a type-less variable upon writing. If the option is disabled, an unknown variable name results in a transfer error. |
Automatically created global variables are retained even after restarting the OPC router. The Variables dialog in the Plug-ins section offers the option to import such runtime-created variables into the configuration; they can then be edited like any other variable.