Programmatically Change Data Binding Source for Shared Variables in LabVIEW

Updated Oct 25, 2020



  • LabVIEW
  • LabVIEW Datalogging and Supervisory Control Module

How do I change the data binding source for shared variables dynamically? 

You can programmatically change the data binding source in LabVIEW using the Datalogging Supervisory (DSC) Module or using LabVIEW's native functions. The steps for each method are detailed below. 

Using DSC Module  

  1. Create a property node by selecting Application Control >> Property Node in the Functions Palette. 
  2. Right click on the property node and select Class >> Shared Variable >> SharedVariableIO

  1. Click on the property node's default property and select Network >> URL.
  2.  Wire a new URL value to this property. 
  3. Extend the property node to add another element to the Property Node and select Network >> Use Binding
  4. Create a constant and set the value to True
  5. Wire a Shared Variable constant to the reference input of the Property Node. See the two methods below to create a Shared Variable constant: 
  • Right-click on the reference terminal and select Create >> Constant
  • Select DSC Module >> Engine Control >> IO Primitive >> Shared Variable Constant from the Functions Palette
  1. Browse to or select the desired Shared Variable in the Shared Variable Constant. If you are working on multiple Shared Variables within a library: 
    1. Use the Get Shared Variable List VI available at DSC Module >> Engine Control >> Get Shared Variable List to retrieve multiple Shared Variable references in an array.
    2. Feed this array into an auto-indexing For Loop and change the URL for each Shared Variable.
Once this functionality is coded in the VI, the LabVIEW DSC Run-Time System is not required if you wish to distribute the executable and are not using other DSC features such as logging, alarming, or security. 
  1. Check the Enable Enhanced DSC Run-Time Support checkbox in the Advanced category of the Build Specifications
  2.  Check the NI Enhanced DSC Deployment Support checkbox in the Additional Installers section of your installer properties.

Using Native LabVIEW Functions

Please note this method will only work on computers with LabVIEW Development System installed. 

  1. Right-click on the block diagram and select Programming >> Application Control >> Invoke Node.

  2. Click on Method and select Library >> Open.
  3. Right-click the path terminal and select Create >> Constant.
  4. Enter the path to the library containing the variable you want to change the binding of.
  5. Right-click the Library.Open terminal and select Create >> Method for Library Class >> Get All Descendents.
  6. Wire the Library.Open terminal on application invoke node to the reference terminal on the library invoke node. 

  1. Add an index array vi to the block diagram by right-clicking and selecting Programming >> Array >> Index Array.
  2. Wire the Get All Descendents terminal into the Array terminal on the index array vi.
  3. Right-click the index terminal and select Create >> Constant.
  4. Enter the index of the variable you would like to change the binding of.
  5. Right-click the element terminal and select Create >> Property for Project Item Class >> Variable Reference.
  6. Wire the element terminal into the reference terminal on the property node.
  7. Right-click the Variable Reference terminal and select Create >> Property for Variable Class >> Network >> URL.
  8. Wire the Variable Reference terminal to the reference terminal on the variable property node.
  9. Right-click on Network.URL and select Change to Write.
  10. Right-click the Network.URL terminal and select Create>>Constant.
  11. Enter the path to the variable to bind to in the following format: \\Computer_name\Library_name\Shared_Variable_name ​

  1. Redeploy the library to use the new binding immediately: 
    1. Right-click on the block diagram and select Programming >> Application Control >> Invoke Node.
    2. Click on Method and select Library >> Deploy Library.
    3. Wire in the same library path from the Library.Open invoke node created in Step 1 above.

Additional Information

Using the native LabVIEW functions only works on computers with LabVIEW Development System installed because the Network.URL property is not available with LabVIEW Run-Time Engine unless the DSC Module is installed.