Navigating across a Structure Using VI Scripting

Requires: VI Scripting

You navigate across a structure any time that you inspect, edit, or create references to a particular part of a structure. Navigating across a structure is a unique navigation task because the elements of a structure are connected by the structure itself rather than by wires. Therefore, to navigate a structure, you must not only be aware of the different elements that compose a structure but also of the properties that return references to these elements. You can combine navigating across structures with other navigation subtasks to accomplish larger navigation goals. Refer to the navigation overview to learn more about how navigating across structures interacts with other navigation tasks.

What to Use

To navigate across a structure, you use properties of the structure to obtain references to different parts of the anatomy of the structure. The properties you need to navigate across a structure depend on the structure that you are navigating. Refer to the following structure anatomies to identify which properties you need to navigate a particular structure.

What to Do

Before you start: Open the Navigating Structures VI in the labview\examples\Application Control\VI Scripting\Finding and Modifying Objects directory for an example that illustrates each step of the following procedure.

 Open Example

Expand the procedure for more information about this specific example.

  1. Obtain a reference to the structure you want to navigate.

    Example Details

    In the example, the scripting VI uses the Traverse for GObjects VI to obtain references to all the Case structures in the target VI.

  2. Use the structure reference to obtain a reference to the element of the structure that is relevant to your overall navigation task.

    Possible structure elements include tunnels, shift registers, Case structure frame names, and so on. Refer to the anatomies of common VI objects for a visual depiction of the parts of different types of structures.

    Example Details

    In the example, the scripting goal is to navigate to and analyze the object that is wired to the case selector. Therefore, the scripting VI uses the Case Structure:Selector property to obtain a reference to the selector tunnel of each Case structure. This reference enables navigation to continue toward the wired object.

  3. Use the reference to the structure element to either edit the element or to continue navigating.

    As the structure anatomies indicate, some elements of a structure provide access to other elements of the structure. For example, you can use a reference to a tunnel to obtain a reference to the inner and outer terminals of that tunnel.

    Example Details

    In the example, the scripting VI uses the reference to the case selector to continue navigating from a node (the case selector) to a connected wire. The scripting VI uses the Tunnel:Outside Terminal property of the case selector to obtain a reference to the outer terminal of the case selector. The scripting VI requires the terminal reference to obtain a reference to the connected wire.

  4. Use the Close Reference function to close every reference to a structure or structure element when you are finished using them.

Caveats and Recommendations

Close all references that you open—An excessive number of open references negatively impacts the performance of a VI. Read about closing VI and object references for more performance details.

Additional Examples