LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I build a subvi that accepts a boolean or numeric data (any kind of data) without using a numeric/boolean control in this subvi?

I want to build a subvi that I want to use with boolean or numeric control, it doesn't matter which.
Is it possible? I am trying to solve the problem using variant data, but if I use a variant control in the subvi, it doesn't work properly. Any idea?

Thanks in advanced for your help!

Graci
0 Kudos
Message 1 of 6
(3,184 Views)
you need to create a polymorphic vi. Build two vis, with the same connector pane. Save them. Then go to File/New.../Other Document Types/Polymorphic VI. Then "Add" your vis. Document the menu and selector columns. That's it.
You will find more information in the LV User Manual :
Chapter 5 - Building the Block Diagram/Polymorphic VIs and Functions/Building Polymorphic VIs.
Chilly Charly    (aka CC)
Message 2 of 6
(3,184 Views)
One note on creating polymorphic VIs. You must have the LabVIEW Professional Development System (which comes in all the developer suites). The Base and Full packages do not include the ability to create them.

Another option would be to use a Varient for your input. This requires a bit more coding inside your subVI to figure out what the data type was and operate on it correctly, but you don't have polymorphic capability, this would be a good choice.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 6
(3,183 Views)
Hi Ed!

I am using Labiew, but on Linux, and I can't use polymorphic vi.
I have tried it using variant data, but I haven't obtained any good result!
My problem is that I have used a variant control in the subvi, but it doesn't work, and I dont know which control I have to use.
Do you have any idea?

Thanks!

Graci
0 Kudos
Message 4 of 6
(3,183 Views)
Using Varients can very involved to determine what data type is connected.

An easier way to do what you want would be to have two input terminals on your subVI. One for boolean, one for the numeric, and one more to specify the data type using an emun. The subVI, checks what data type is specified and can then run the correct code.

I've attached a simple example that shows how this could be done.

Hope this helps.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 5 of 6
(3,183 Views)
If you need to use variants, there is a simple way to solve your problem : a boolean can take only 2 values: true or false. You can therefore compare the vi input with either T or F variant constant values. If neither value fits, that means that your input is something else. If you accept to limit the functionality of your vi to either boolean or numerics, that could work.
See the example below.
Chilly Charly    (aka CC)
0 Kudos
Message 6 of 6
(3,183 Views)