Owning Palette: Shared Variable
Installed With: Base Package
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»Browse... 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 The behavior of the Shared Variable node differs when it is bound to a physical I/O channel. Refer to the Using I/O Variables topic for information about I/O variables. |
![]() | 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 VI and functions to read or write shared variables from other platforms. |

![]() |
Variable specifies 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. | ||||||
![]() |
ms timeout specifies a timeout period in milliseconds for a Shared Variable node configured to read data. The shared variable waits the specified amount of time for new data, and the timed out? indicator returns whether the shared variable read new data in the specified time period or timed out. To add a ms timeout input to the Shared Variable node, right-click the Shared Variable node and select Show Timeout from the shortcut menu. You only can enable a timeout period for network-published Shared Variable nodes configured to read data. | ||||||
![]() |
error in describes error conditions that occur before this VI or function runs.
The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurred before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code.
Use exception control to treat what is normally an error as no error or to treat a warning as an error.
Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
| ||||||
![]() |
Variable specifies 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. | ||||||
![]() |
timed out? displays whether a Shared Variable node read new data within the specified timeout period or timed out. To add a timed out? output to the Shared Variable node, right-click the Shared Variable node and select Show Timeout from the shortcut menu. You only can enable a timeout period for network-published Shared Variable nodes 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.
Right-click the error out front panel indicator and select Explain Error from the shortcut menu for more information about the error.
|
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. |
If you publish a shared variable with less than 8 kilobytes of data, it can take up to 10 milliseconds for LabVIEW to send that data over the network. The Flush Shared Variable Data VI allows you to flush the buffer immediately and eliminate this delay.