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

Creating Global Variables

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

You can create several single global VIs, each with one front panel object, or if you want to group similar variables together, you can create one global VI with multiple front panel objects.

Complete the following steps to create a global VI with multiple front panel objects.

  1. Add a global variable to the block diagram.

  2. Use the Operating tool or Positioning tool to double-click the global variable node to display the front panel window of the global VI.
  3. Add controls and indicators to the front panel window the same way you do in a standard front panel window.
Note  LabVIEW uses owned labels to identify global variables, so label the front panel controls and indicators with descriptive owned labels.
  1. Save and close the global VI.
  2. Return to the block diagram of the original VI and right-click the global variable node and select a front panel object from the Select Item shortcut menu. The shortcut menu lists all the front panel objects that have owned labels. You also can use the Operating tool or Labeling tool to click the global variable node and select the front panel object from the shortcut menu.

Complete the following steps to use a global variable in other VIs.

  1. Click the Select a VI icon or text on the Functions palette, navigate to the directory where you saved the global VI, and double-click the VI.
  2. Add the global variable to the block diagram. By default, the global variable is associated with the first front panel object with an owned label you added to the global VI.
  3. Right-click the global variable node you added to the block diagram and select a front panel object from the Select Item shortcut menu to associate the global variable with the data from another front panel object.
Note  Use a global variable only when you cannot route a wire through multiple VIs to share data. For example, if a file path is changed in one VI and another VI must open that path, there might not be a logical way to wire the path through numerous calling VIs. Using a global variable to hold the path data might be the best choice.

 

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