Complete the following steps to create and configure a shared variable.
 |
Note Shared variables can only be created, configured and hosted on Windows systems. You can use the DataSocket VIs and functions to read or write shared variables from other platforms. If you have a VI with a Shared Variable node that was configured on a Windows system, you can also move that VI to another platform. |
- In the Project Explorer window, right-click a project library or folder under a project library and select New»Variable to display the Shared Variable Properties dialog box. You also can right-click an existing shared variable and select Properties from the shortcut menu to display the Shared Variable Properties dialog box.
 |
Note If you right-click a target or a folder that is not inside a project library and select New»Variable from the shortcut menu to create a shared variable, LabVIEW creates a new project library and places the shared variable inside. |
- Enter a name for the shared variable in the Name text box.
- Select the data type for the shared variable from the Data Type pull-down list. If you do not see the data type you want to use, select From Custom Control to use the data type of a custom control.
- Select the type of shared variable you want to create from the Variable Type pull-down list. Select Network-Published from the Variable Type list to create shared variables that you want to read and write on remote computers and targets on the same network. Select Single-Process from the Variable Type list to create shared variables that you want to read and write on a single computer.
Configuration options vary depending on the Variable Type you select. LabVIEW modules and toolkits you have installed might provide additional shared variable types, configuration options, and limitations. Refer to the documentation for the LabVIEW module or toolkit for more information about the shared variable types, configuration options, and limitations that product adds to shared variables.
- (Optional) If you select Network-Published from the Variable Type list, place a checkmark in the Use Buffering checkbox to enable client-side buffering for the shared variable data. Depending on the data type you select from the Data Type pull-down list, you might need to enter values in additional fields in the Use Buffering section.
 |
Note You can configure buffering only for network-published shared variables. |
- (Optional) Place a checkmark in the Single Writer checkbox to accept changes in value from only one writer at a time.
- Click the OK button to create the shared variable.
You also can bind the new shared variable to an existing shared variable or to an NI-PSP data item.
You also can use the Variable Manager dialog box to edit, create, and monitor shared variables outside of the project environment.
 |
Note If you deploy a LabVIEW project library that includes shared variables and then use the Variable Manager dialog box to create new shared variables in the same project library, the new shared variables only exist until you deploy the project library again. |
You also can use the Variable Reference property with the Variable properties to configure shared variables programmatically.
 |
Note In LabVIEW 8.0, you can create shared variables outside of a project library using the VI Server methods. To correct errors you might experience because the shared variable is not in a project library, you can use the AddSharedVariableToLibrary VI in the labview\vi.lib\Utility\Variable directory to programmatically add shared variables to a library. You also can use the CreateOrAddLibrary polymorphic VI to programmatically add a library to a project or a parent item such as a target, folder, or another library. |
Open VI