LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adaptable Terminal Type

Hi guys,
 
I have seen VIs such as the "Unflatten from String" that take a "Type" input and can adapt their input/output value terminals to that type. Basically if you connect a string constant to the type terminal then the value terminal becomes a string, but if you connect an integer, then the value output is of type integer.
 
How do they do that?? I would like to do the same for some of my VIs.
 
Thanks.
 
 
 
 
 
 
 
 
 
 
 
 
Message 1 of 8
(4,344 Views)
Message 2 of 8
(4,343 Views)
There are also XNodes, which do work like the primitives, but they are much more complicated and not supported by NI. You can find out more in the LAVA forums' XNodes forum, but I would also advise that you use a polymorphic VI if you really need this.

___________________
Try to take over the world!
Message 3 of 8
(4,331 Views)
The other way to do this in LabVIEW is with LabVIEW Classes and dynamic methods. Granted, this is a very limited option in the overall scope of LabVIEW, but I though it would be worth mentioning. Here's how it goes.

If you have a child that inherits from a parent, then that child can call all the parent's methods. The connector pane for the parent method will usually have a parent object input and output. All other things being equal, if you wired a child up to the parent object input, you should still have a parent object output as defined by the subVI, but LabVIEW is smart enough to propogate the child type directly to the output. So you don't have to downcast when calling parent methods. Pretty cool stuff.

If that doesn't make any sense to you, you might consider reading up on LVOOP for fun. I'm not claiming this technology solves the problem you mentioned, but it's worth noting. 🙂
Jarrod S.
National Instruments
Message 4 of 8
(4,327 Views)
Thanks guys.
 
A quick follow up about polymorphic VIs: Is there a performance hit with using polymorphic VIs? For example, if a VI takes in an integer as an input, is there a performance difference if the VI is coded as a simple VI with an integer terminal versus the case where it is coded as a polymorphic VI?
 
Thanks again.
Message 5 of 8
(4,313 Views)
Polymorphic VIs only have different Edit Mode behavior. During run-time (when they can no longer switch between instances), they are exactly like any other subVI.
Jarrod S.
National Instruments
Message 6 of 8
(4,306 Views)
But there is a memory hit on having to load all the instances.

___________________
Try to take over the world!
Message 7 of 8
(4,299 Views)
There's also the variant control.

Message 8 of 8
(4,278 Views)