To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example shows how to convert shared variable addresses between APIs.
Description
There are multiple ways to access shared variables from LabVIEW without using an actual shared variable node. Unfortunately, the address formatting used within these APIs is often incompatible with other APIs. This example allows the user to convert shared variable addresses (formatted as strings) between the following APIs.
Some APIs return "." or "My Computer" as an alias for localhost. All APIs will recognize "localhost", so this VI also replaces "." and "My Computer" with "localhost" if found. All other target names will be preserved in the converted address (also IP addesses).
The VI is designed to be used as a SubVI, so you can pass the string and desired output type in and receive the correctly formatted output address.
Example conversion (DataSocket --> Shared Variable API):
psp:\\localhost\OPC Library1\_ActiveTagCount --> ni.var.psp://localhost/OPC Library1/_ActiveTagCount
Example conversion (Shared Variable API --> DataSocket):
ni.var.psp://192.168.0.1/OPC Library1/_ActiveTagCount --> psp:\\192.168.0.1\OPC Library1\_ActiveTagCount
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.