LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sub-VI with variant indicator

Hi,

i want create some sub-vi that make some transformations of 2-d array. Because it doesn't matter what type of array (numbers, strings, ...), i maked it as vi that get variants as input parameters and it return resulted array also as array of variants.
So, my problem is, how can i do, that type of indicator will change according to type of input variant. (Sorry for my english)
0 Kudos
Message 1 of 2
(2,576 Views)
nchernin,

The solution depends of the usage you make of the VI.

If you have relatively few different datatypes arrays, you can write a VI for each datatype and create a polymorphic VI. At edit time, the node will be linked to the correct VI depending of the type of wire you connect. There is no conversion to variant overhead, which can be noticeable for large arrays. Polymorphic VIs are development-time tools.

Variants are Run-time tools as the incoming datatype is not known until the subVIs receives it when called. Using variants, as you do, the input is automatically converted to variant data (with conversion overhead). You make array manipulation in the called subVI but the output indicator will stay a variant. Conversion to original datatype m
ust be made on the calling diagram, where the datatype is available for a "To G data" conversion node.
If you use the subVI very often, you can make a code snippet VI: on the diagram of a new VI, drop the array manipulation subVI and a "To G Data" node and make the appropriate connections. Then put the VI ot the function palette with the "Merge VI" option. Everytime you will select the VI on the palette, the diagram code (the the VI icon) will be inserted in the diagram so you only have to connect the incoming array wire.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 2
(2,576 Views)