Represents a shared variable on the block diagram. To bind a Shared Variable node to a shared variable from the active project, place a Shared Variable node on the block diagram and double-click it or right-click it and select Select Variable from the shortcut menu to display the Select Variable dialog box. You also can drag a shared variable from the Project Explorer window onto the block diagram of a VI in the same project to create a Shared Variable node.
![]() | Note You can create, configure, and host shared variables only on Windows or RT targets with the LabVIEW Real-Time Module. You can use the DataSocket VIs and functions to read or write shared variables from other platforms. |
| Block Diagram Inputs |
| Block Diagram Outputs |
| Parameter | Description |
|---|---|
| Variable | The value to write to the Shared Variable node. You must wire a value to this input when the Shared Variable node is configured to write data, or the VI will be broken. This input is available only when the Shared Variable node is configured to write data. |
| error in (no error) | Describes error conditions that occur before this VI or function runs. |
| Parameter | Description |
|---|---|
| Variable | The current value of the shared variable that the Shared Variable node represents. This output is available only when the Shared Variable node is configured to read data. |
| timestamp | Displays the timestamp data for the shared variable. To add a timestamp output to the Shared Variable node for a single-process shared variable, you must first place a checkmark in the Enable timestamp checkbox on the Variable page of the Shared Variable Properties dialog box, and then right-click the Shared Variable node and select Show Timestamp from the shortcut menu. You can use this output only with shared variable nodes that are configured to read data. |
| error out | Contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. |
When you drag a shared variable from the Project Explorer window to the block diagram or place a Shared Variable node on the block diagram, LabVIEW configures the Shared Variable node to read data. To configure the Shared Variable node to write data, right-click the Shared Variable node and select Change to Write from the shortcut menu.
To specify how a Shared Variable node connects to a shared variable, you can set the node to absolute or target-relative. An absolute Shared Variable node always connects to the shared variable on the target on which you created the shared variable. A target-relative Shared Variable node always connects to the shared variable on the target on which you run the VI that contains the Shared Variable node. To change an absolute Shared Variable node to target-relative, right-click the Shared Variable node and select Change to Target Relative from the shortcut menu. To change a target-relative Shared Variable node to absolute, right-click the Shared Variable node and select Change to Absolute from the shortcut menu.
A network-published Shared Variable node on a VI uses an .aliases file to determine the IP address of the computing device in the project where the Shared Variable is deployed. When you run a VI in a LabVIEW project, the VI finds the project's .aliases file and uses that to resolve aliases. The project keeps entries for each computing device in the project in the .aliases file, and updates the IP addresses when they change. When the VI runs in the main application instance, the VI uses the LabVIEW.aliases file in the same directory as LabVIEW.exe to find aliases. This file does not update automatically like the project .aliases file. You must add the IP address to the .aliases file. If the VI fails to find the alias, the Shared Variable node uses the last known IP address. If the Shared Variable is no longer deployed at the last known IP address, the Shared Variable node will return an error.
![]() | Note Opening a VI containing a Shared Variable node in a project where the Shared Variable node cannot find its associated shared variable in the Project Explorer window causes the Shared Variable node to break. Any front panel controls associated with the missing shared variable also break. (Windows) This behavior is specific to Windows and only occurs when you open the VI in a project. If you open the VI in the main application instance, you do not receive notification of missing shared variables. |
![]() | Note If you are using a network-published Shared Variable node that is configured to read data, you must run each Shared Variable node before the node subscribes and starts receiving buffered values. |