LabVIEW 2018 Help
View Product Info
DOWNLOAD (Windows Only)
Polymorphic VIs adapt to different data types. A polymorphic VI is a collection of VIs with the same connector pane patterns. Each VI in the collection is an instance of the polymorphic VI, and each instance has at least one input or output terminal that accepts a different data type than in the other instances.
For example, the Read Key VI is polymorphic. Its default value terminal accepts Boolean; double-precision, floating-point numeric; 32-bit signed integer numeric; path; string; or 32-bit unsigned integer numeric data.
Build polymorphic VIs when you perform the same operation on different data types and the operation must be implemented differently across data types. If the operation can be implemented in similar ways for different data types without significant customization for a specific data type, build malleable VIs instead.
Complete the following steps to build a polymorphic VI.
- Create two or more VIs with the same connector pane pattern. Make sure the connector panes have corresponding input and output terminals—if a terminal on the connector pane of one VI is an input, the corresponding terminal of the connector pane of the other VI(s) also must be an input or it must be unused. The same applies for output terminals. The VIs do not have to have similar data types or similar subVIs and functions.
- Select File»New to display the New dialog box.
- From the Create New list, select Polymorphic VI.
- Click the OK button to display the Polymorphic VI window.
- Click the Add button to display a file dialog box.
- Select one of the VIs you created to include as an instance in the polymorphic VI, and click the OK button. The VI appears at the top of the Instance VIs list. The instance at the top of the list is the default instance of the polymorphic VI and determines the default connector pane for the polymorphic VI.
- Repeat steps 5 and 6 to include other VIs. Any VIs that do not conform to the default connector pane pattern appear with a broken icon . You still can save the polymorphic VI. To remove an instance from the polymorphic VI, select the instance and click the Remove button.
- (Optional) To change the order of the instances, select an instance in the list and click the Move Up arrow button or the Move Down arrow button. You also can select an instance in the list and drag it to a new position in the list.
||Note Double-clicking a VI in the Instance VIs list opens the VI.|
- (Optional) To specify how the polymorphic VI appears on the block diagram, configure the Block Diagram Appearance options.
- Click the Edit Icon button to create an icon for the polymorphic VI.
- Create a description for the polymorphic VI by selecting File»VI Properties and selecting Documentation from the Category pull-down menu. The polymorphic VI description is not associated with descriptions of the instance VIs that compose the polymorphic VI. If you select Draw Instance VI Icon in the Polymorphic VI window, create descriptions for each instance VI because LabVIEW displays the connector pane and description of the instance VI in the Context Help window when you move the cursor over the polymorphic VI. The Context Help window also displays a description of each instance as you move the cursor through the shortcut menus of the polymorphic VI or its selector.
- Select File»Save to save the VI.
- Select File»Close to close the Polymorphic VI window.
You also can add or remove an instance in an existing polymorphic VI, edit the shortcut menus of a polymorphic VI and its selector, and manually select the instance of a polymorphic VI.
Choosing between Malleable VIs and Polymorphic VIs