What Are Polymorphic VIs? Where Can I Use Them?

Updated Nov 29, 2023

Reported In

Software

  • LabVIEW

Issue Details

What are Polymorphic VIs? Where can I use them?

How can I make a dynamic subVI that has a different output data type depending on the input?

Solution

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.

When can I use a polymorphic VI:

Polymorphic VIs are very helpful when you want to perform similar or identical operations on data of different types. The input data type decides which instance of the polymorphic VI is executed. The polymorphic structure allows the user to apply a VI correspondence to different instances with similar functions, and these different instances process data of different data types. A polymorphic VI doesn't mean that all of its input or output terminals must be polymorphic.

A typical example - Array Sorting. You can sort data from different data types, such as numeric arrays, string arrays, or file path arrays, all of which can be sorted using the same polymorphic VI. You can also use the same polymorphic VI for arrays of different dimensions.

Create a polymorphic VI:

To create a polymorphic VI, choose File » New. In the pop-up dialog box, and select Polymorphic VI under the VI directory. Then you can add different polymorphic instances to your new polymorphic VI. Refer to Building Polymorphic VIs for more information.