Complete the following steps to pass a control reference to a subVI and use it to modify properties or methods of the referenced control or indicator.
- Right-click the front panel control or indicator of the main VI to which you want to create a reference and select Create»Reference from the shortcut menu. LabVIEW attaches a strictly typed control reference to the mouse cursor. Drop the reference on the block diagram of the main VI.
You also can create a control reference by selecting a control refnum on the Controls palette, adding it to the front panel of the subVI, and adding an object of the same type as the referenced object to the front panel control refnum shell. This creates a non-strictly typed control reference.
- Open the subVI, or create a new VI, to which you are passing the control reference. From the block diagram of the main VI, drag the control reference to the front panel of the subVI to create a control refnum control for the control reference on the subVI front panel. A corresponding control reference terminal appears on the subVI block diagram.
||Note If you drag the control reference to the block diagram, you only copy the control and control reference rather than create a control refnum control.|
- Complete the following steps to modify properties or methods of the front panel object associated with the control reference by creating a Property Node or Invoke Node.
You also can select a Property Node or Invoke Node on the Functions palette and place it on the block diagram. Right-click the node and select a property or method from the Properties or Methods shortcut menus.
- Right-click the control reference on the block diagram of the VI.
- Select Create»Property for (type name) or Create»Method for (type name) and select a property or method from the shortcut menus.
- Click to place the node on the block diagram of the subVI.
- Wire the control reference to the reference terminal of the Property Node or Invoke Node. The Property Node or Invoke Node references the control in the main VI.
- Set up the terminals on the connector pane of the subVI, including the control reference.
- On the main VI, add the subVI to the block diagram and wire the control reference to the control reference terminal of the subVI.
Refer to the Control References VI in the labview\examples\Application Control\VI Server\Control References directory for an example of controlling front panel objects programmatically from a subVI.