Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Navigating from a Node to a Wire Using VI Scripting

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

Requires: VI Scripting

You navigate from a node to a wire any time that you use a reference to a node to obtain a reference to a connected wire. Navigating from a node to a wire is a navigation subtask that you can combine with other navigation subtasks to accomplish larger navigation goals. Refer to the navigation overview to learn more about how navigating from a node to a wire interacts with other navigation tasks.

What to Use

This VI Scripting task requires the following objects:

Node:Terminals[] Visible Terminal Indexes Index Array Terminal:Connected Wire Close Reference

What to Do

Before you start: Open the Navigating Nodes and Wires 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.

Expand the procedure for more information about this specific example.

  1. Obtain a reference to a node.

    Example Details

    In the example, the scripting VI uses the Traverse for GObjects VI to obtain references to all the Function nodes in the target VI. The Case structure checks the style of each Function node so that navigation continues only from the Function nodes whose style is One Button Dialog.

  2. Use the Node:Terminals[] property to obtain references to the terminals of the node.

    Example Details

    In the example, the Node:Terminals[] property appears as Function:Terminals[] because the reference is a Function reference. Because Function is a subclass of Node, Function inherits the Terminals[] property of Node.

  3. Refer to the Context Help window of the node to identify the terminal index of the terminal that connects the node to the destination wire.

    You must display additional VI scripting information in the Context Help window to cause the connector pane in the Context Help window to display a bracketed number next to each terminal. This number represents the index in the Terminals[] array where the reference to the corresponding terminal is stored.

    Example Details

    In the example, the scripting VI requires the index of the button name input of the One Button Dialog function. According to the Context Help window for the One Button Dialog function, the index for that input terminal is 1.

  4. Use the Index Array function with the desired terminal index to obtain a reference to the desired terminal in the Terminals[] array.
  5. Use the Terminal:Connected Wire property of the returned terminal reference to obtain a reference to the wire connected to that terminal.
  6. Use the returned wire reference to either modify the wire or to continue navigating.

    Example Details

    In the example, the scripting VI uses the wire reference to continue navigating from a wire to a node by using the Wire:Terminals[] property of the wire.

  7. Use the Close Reference function to close the node reference, the terminal reference, and the wire reference when you are finished using them.

Caveats and Recommendations

  • Display terminal indexes in the Context Help window—You can access the desired terminal in the Node:Terminals[] array if you know the index of the desired terminal.
  • Beware of invalid references in the Node:Terminals[] array—The Node:Terminals[] array contains one element for every terminal of a Node. However, each element is a valid reference to a terminal only if the terminal is wired. Because many VIs and functions have optional inputs that are not always wired, the array of terminals often contains invalid references for these terminals. Therefore, if you are not sure whether a specific terminal is wired, check the corresponding element in the terminals array to see if it is an invalid reference before attempting to use it elsewhere in a scripting VI.
  • 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

Refer to the Navigation Overview VI in the labview\examples\Application Control\VI Scripting\Finding and Modifying Objects directory for a complete navigation example that includes navigating from a node to a wire and navigating across a structure.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit