From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pass an enum into a VI that can process any type of enum

I would like to create a VI that can take any enum as an input terminal, use the format into string to get the text value, and then do something appropriate with the enum value and it's associated text. Using a integer input will not work because it will not work properly with format into string.  To see what I'm doing with that, see http://forums.ni.com/ni/board/message?board.id=170&message.id=187150&query.id=596654#M187150

 

What I want to do is perform this formatting inside a VI that accepts ANY enumerated type as it's input.

0 Kudos
Message 1 of 6
(5,753 Views)

Hello,

 

In a sub-vi, you will need to pass a reference to the enum that you are trying to evaluate, cast the reference to an enum type, and access properties to index to the currently selected string.  You must use a generic control reference as your input to the sub-vi since the enum can be a type def, or a strict type def.  The attached vi (LV8.6) will show you how to retrieve the currently selected enum index and the string value of the current selection.  To call it, pass a reference to the enum you wish to evaluate.  This should get you started on your project.

 

-cb

Download All
Message 2 of 6
(5,744 Views)

I cannot see your VI, but from the comment on the pic, I can say that it need not be a strictly typecast Enum reference. Just a normal Enum class serve the purpose.

 

Pl correct me if I m wrong...

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 3 of 6
(5,741 Views)

You can also simply use a variant as the control in the subVI. This will allow you to wire the enum directly to the subVI. Go to OpenG and get the OpenG LabVIEW Data Tools library. In the subVI just use the "Get Strings From Enum" VI. This VI will return the enum string as well as the array of strings. You can get the value from a simple Search 1D Array.

 

 

Download All
0 Kudos
Message 4 of 6
(5,735 Views)
Or you could use GetNumericInfo.vi provided with LabVIEW to do the same thing, found in the library vi.lib\utility\VariantDataType\VariantType.lvlib.
Message 5 of 6
(5,674 Views)

Hello:

I'm trying to do something similar: I have a ton of existing sub vis that take in a strict type enum as a control. The application functionality requires a new enum now that has new string values and a new size (# elements).

Within the subvis that use the origingal enum control I need to either use the new enum or the old one depending on the UUT.

I've tried to understand the pictures that show the generic enum references but I'm not sure how to create a generic enum reference to act as the input to the subvis.

Thanks

Mike 

0 Kudos
Message 6 of 6
(5,671 Views)