LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enumerators with Non-Contiguous Values?

I have seen enumerators in labview that have non contiguous values, but i cannot figure out how to create them myself. Usually they are associated with calls to external .net or .dll libraries.

In this case the return values of a function I am calling are enumerated in hexedecimal, and are basically 1 value per bit. Is it possible to create such an enum? Of course I can handle the result as an int, but this is not as readable.

Thanks in advance

0 Kudos
Message 1 of 9
(4,204 Views)
You can display it as a ring control... To the user, it would be transparent (and that is what you probably saw).  Otherwise you will have to bit twiddle to get contiguous values for the enum.

Message Edited by Stradis on 07-09-2007 02:35 PM


Paul
Message 2 of 9
(4,189 Views)
It must have been a ring. Thank you very much, that worked great! (even in hex)

0 Kudos
Message 3 of 9
(4,179 Views)

those are called "sparse enums".

See here for a tool developed by Jean-Pierre Drolet.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 9
(4,173 Views)
Actually, as i started using the rings, they are next to useless. The enum data type is really what i wanted for use in case structures, Format Into String, etc. Being able to define the value of enums is something every language Im familiar with allows (VB, C++, etc)... wonder why they decided not to let you do it in LV?

Guess its bit-twiddling for me!

0 Kudos
Message 5 of 9
(4,149 Views)
That library converts the names fine, but doesnt handle the values... Handy little utility though! Thanks

0 Kudos
Message 6 of 9
(4,146 Views)
Why didn't the ring control work out for you?  Was it because the numeric value is what appears in the case structure instead of the name of that value like with the enum?
Brian Coalson

Software Engineer
National Instruments
0 Kudos
Message 7 of 9
(4,126 Views)
Yes basically, the enumerator is a data type, while a ring is a control with the data type int (or whatever you choose). there is no type data. So format into string does not return the string value of the enum.

Enums are very handy because they are a pre defined list of string - value pairs. Rings are great as input controls, but do not carry the string value pairs with them. When the values in a ring are not continuous, it is harder to relate the value to the string (ie, the value is not the index of the string).

Its not a major hurdle, there are workarounds. Just thought maybe i was missing something since most other languages can do it.
0 Kudos
Message 8 of 9
(4,115 Views)
Yes, unfortunately, beyond the workaround, there is not a way to create those sparse enums.  You can always create a product suggestion to let R&D aware of the fact that our customers would like to see such a capability.  They regularly look over this list to determine what should be included in new releases, so I would highly suggest taking the time to fill out a product suggestion.  Have a great day.
Brian Coalson

Software Engineer
National Instruments
0 Kudos
Message 9 of 9
(4,090 Views)