VI Reference

From LabVIEW Wiki
(Redirected from VI reference)
Jump to: navigation, search

A VI Reference [VI-Ref] is a reference to a VI, that is 'somewhere' loaded into the memory of a computer. This VI-Ref can than be used to access and possibly modify this VI, its components and data by means of VI Server.
In order to open a VI-Ref one needs to specify the VI Server to work on, the Application Reference [Appref]. This defaults to the local machine, but can be any active machine that can be reached via TCP/IP connection. Use the Open Application Reference node in the Application Control palette. The LabVIEW Help states:

The Open Application Reference Node returns a reference to a VI Server Application that runs on the specified computer. If no computer is specified, it defaults to the local machine.
The returned application reference can be used in conjunction with the Property and Invoke Nodes to get or set properties and invoke methods on the application, including opening a VI Reference.

The AppRef should be closed with the Close Reference function, if it is no longer required, allthough LabVIEW will close it as soon as no instance uses it any longer (usually when the top-level VI of the calling chain to this AppRef goes idle).

With an AppRef one opens a VI-Ref using the Open VI Reference node in the very same palette. Again the LabVIEW Help states:

This function returns a reference to a VI, custom control, or global variable as specified by its name or path to its file location on disk. VI-Refs should as well explicitely be closed when no longer needed; allthough LabVIEW closes them under the same conditions as for AppRefs.
A VI-Ref can be counted as similar to function pointers in other programming languages, but LabVIEW can handle such function pointers across the network.

Having obtained the VI-Ref, one can (recursively) access all of its properties and components and can as well call the VI or perform some actions with it. The former is done using Property Nodes. The VI can be called using the Call By Reference node, while the methods for the VI are accessibel using the Invoke Node. Amoung the methods are Front Panel specific ones like open/close/move/scale etc, operation methods like setting or retrieving control data or running or aborting the VI and printing methods.

See Also