You can use VI Scripting to interact with the connector pane of a VI programmatically to accomplish any of the following tasks:
Selecting a connector pane pattern for a subVI
Assigning a control to a terminal on a connector pane
Navigating across a connector pane
Defining whether a terminal of a subVI is required, optional, or recommended
This topic highlights the first two tasks. Refer to the Connector Pane methods for more information about interacting with a connector pane programmatically.
What to Use
This VI Scripting task requires the following objects:
Before you start: Open the Add Terminals to Connector Pane VI in the labview\examples\Application Control\VI Scripting\Connector Pane directory for an example that illustrates each step of the following procedure.
Open Example
Expand the procedure for more information about this specific example.
Determine the connector pane pattern you want the VI to have.
Connector pane patterns are denoted by a pattern index between 4800 and 4835. By default, connector panes use pattern 4815.
You can use one of the following approaches to identify which pattern index to use.
Refer to the Connector Pane Pattern Reference VI located in the labview\examples\Application Control\VI Scripting\Connector Pane directory for a complete mapping of patterns to their indexes.
Use the ConnectorPane:Pattern property of another VI to programmatically obtain the pattern index of that VI.
Example Details
In the example, the scripting VI enables the user to select the connector pane pattern at run time. Therefore, the scripting VI uses a control to determine the connector pane pattern.
Note Because the Connector Pane Pattern control accepts any integer, this example should check the value of that control to ensure that it is within the 4800..4835 range of acceptable pattern indexes. For simplicity, the example omits this step.
Use the Connector Pane:Pattern property to set the connector pane to your chosen pattern.
In the example, the scripting VI uses the Panel:Controls[] property of the front panel of the target VI to obtain references to all front panel controls.
Determine how you want to map these controls to the connector pane terminals.
Refer to the LabVIEW Style Checklist for guidelines about assigning controls and indicators to connector panes that are visible to your users.
Example Details
In the example, the only goal of the scripting VI is to assign all controls to a terminal. Therefore, the scripting VI does not have criteria for how to map the controls to the terminals.
To identify the terminal index that corresponds to each terminal in your chosen pattern, refer to the Connector Pane Pattern Reference VI mentioned in step 3.
Example Details
In the example, the scripting VI iterates across the entire Panel:Controls[] array, assigning each control to the next terminal index of the connector pane. This approach does not require knowledge of specific terminal indexes because the scripting goal does not require the controls to be wired to the connector pane in a specific way.
Note Because it is possible in the example for the chosen connector pane pattern to have fewer terminals than there are controls on the front panel, it is also possible for the ConnectorPane:Assign Control To Terminal method to return an error. Refer to the Caveats and Recommendations section of this topic for information about avoiding this error.
Use the Close Reference function to close each open object reference when you are finished using it.
Example Details
In the example, the scripting VI closes the reference to the front panel, the controls, the connector pane, and the target VI.
Caveats and Recommendations
Use caution when you change a connector pane pattern that has pre-existing control assignments—When you replace a connector pane pattern with a different pattern, LabVIEW reassigns the controls that were previously assigned to terminals on the old pattern to terminals on the new pattern. However, the new assignments do not preserve the terminal indexes or relative locations from the old pattern. Therefore, you can rely only on knowledge of terminal assignments that you obtain after the most recent pattern change.
Ensure that the pattern of a connector pane has enough terminals to accommodate the terminal indexes that you plan to use—The Connector Pane:Assign Control to Terminal method returns an error if the pattern of the referenced connector pane does not have enough terminals to accommodate the terminal index that you wire to the method. Use the ConnectorPane:Number of Connection Terminals property of the relevant connector pane to verify that the connector pane has enough terminals for the terminal index that you want to use.
Close all references that you open—An excessive number of open references negatively impacts the performance of a VI. Read about closing VI and VI object references for more performance details.