Variable Identifier URLs

LabVIEW 2018 Help

Edition Date: March 2018
Part Number: 371361R-01
View Product Info

DOWNLOAD (Windows Only)

LabVIEW 2016 Help
LabVIEW 2017 Help
LabVIEW 2018 Help
LabVIEW 2019 Help
LabVIEW 2020 Help

LabVIEW identifies each shared variable with a variable identifier URL. To read and write shared variables programmatically, you can specify the variable identifier URLs of those shared variables with the shared variable refnum in input of the Shared Variable functions.

Note  You also can search for shared variables programmatically to read and write multiple shared variables with relatively little LabVIEW code.

Shared Variable Architecture

The following list summarizes the set of LabVIEW constructs that relate to shared variables and variable identifier URLs.

  • Shared Variable—A memory space that you can read data from and write data to.
  • PSP Variable—A data item published on the network using the NI Publish-Subscribe Protocol (NI-PSP). Common examples of PSP variables include network-published shared variables, I/O variables with network-publishing enabled, and DAQ channels published through the NI-DAQmx I/O server.
  • I/O Variables—Shared variables that use the NI Scan Engine for single-point access to I/O data.
  • Variable Container—A set of variables. The most common type of variable container is a project library. However, other items such as I/O modules, Wireless Sensor Network (WSN) nodes, and EtherCAT devices also can serve as variable containers. You can use the Browse Variable Object dialog box to find all the variable containers currently deployed on the network.
  • Variable Engine—A run-time component that manages a hierarchy of variable containers and variables.
  • Project Library—A collection of VIs, type definitions, shared variables, palette files, and other files, including other project libraries. A project library that includes shared variables is a variable container, but not all variable containers are project libraries.
  • Target Name—The name assigned to a target item, such as My Computer or an RT target, in a LabVIEW project.
    Note  (Real-Time Module) You can use the Name field on the General Properties page of the RT Target Properties dialog box to specify an RT target name.

Variable Identifier URL Syntax

The URL syntax of a variable identifier is:

[Variable Engine]://[Host Name]/[Container Name]/[Variable Name]

You must specify the Container Name and Variable Name components for all variable identifier URLs. However, you can omit the Variable Engine if it is implied by the class. You also can omit the Host Name if the variables are hosted on the same computer where the VI runs.

For example, the following LabVIEW project contains network-published shared variables, which are listed under the Network Variables.lvlib container, and I/O variables, which are listed under the I/O Module1 container.

The following table includes the full variable identifier URLs for several of the variables in this project.

Variable Name Variable Type Variable Identifier URL
Network Variable1 Network-Published Shared Variable ni.var.psp://My Computer/Network Variables/Network Variable1
AI0 I/O Variable CompactRIO Target/I%2FO Module1/AI0
Network Variable3 Network-Published Shared Variable ni.var.psp://RT CompactRIO Target/RT Network Variables/Network Variable3

The variable identifier URL is not case sensitive. However, you must replace reserved characters with the corresponding escape codes to prevent parsing errors. For example, you must replace the character with the escape code %2F.

The Variable Engine component of the URL depends on the type of variable you plan to read or write. The following table includes the Variable Engine URL for each type of shared variable that the Shared Variable functions support.

Type Variable Engine URL
Network-published shared variable, I/O variable, or I/O alias (remote access) ni.var.psp
I/O variable or I/O alias (local access)

You can use either the PSP Variable Engine or the I/O Variable Engine to access a network-published I/O variable or I/O alias. Use the I/O Variable Engine ( to read or write a network-published I/O variable or I/O alias locally. Use the PSP Variable Engine (ni.var.psp) to read or write a network-published I/O variable or I/O alias remotely.

The Variable Engine component of the URL is implied and therefore optional when using one of the following classes:

  • PSP Variable Engine
  • I/O Variable Engine
  • PSP Variable Container
  • I/O Variable Container
  • PSP Variable
  • I/O Variable

In this case, you can omit the Variable Engine component of the URL and use the following URL syntax:

//[Host Name]/[Container Name]/[Variable Name]

If you are using a generic class that does not imply the Variable Engine and you do not specify the Variable Engine, LabVIEW attempts to resolve the variable identifier URL by searching variable engines in the following order of precedence.

  1. I/O Variable Engine
  2. PSP Variable Engine

In this case, if a matching URL exists in multiple engines, LabVIEW uses the first matching URL.

The [Host Name] component of the variable identifier URL is optional. You can specify the host name as a DNS name, a target name, or an IP address. However, if you do not specify a host name in the variable identifier URL, LabVIEW assumes the host is the same computer where you run the VI. You also can use the string localhost to explicitly specify the computer where you run the VI. To avoid name collisions, use unique names whenever possible.

If you do not need to specify a host name, you can use the following URL syntax:

/[Container Name]/[Variable Name]

If the host name you specify can be interpreted in more than one way, for example both as a project name and as a DNS name, LabVIEW searches for a valid interpretation of the specified host name in the following order of precedence.

  1. Target name (as specified in the LabVIEW project)
  2. DNS name
  3. IP address

The name of each shared variable in a container must be unique. However, because the variable identity includes the container name, variables in different containers can share the same variable name and still maintain unique variable identities.


Not Helpful