ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enum with arbitrary values

Is it possible to define an enum with arbitrary values as in the following C line :

enum { MINE = 5, YOURS = 12 }

oz
0 Kudos
Message 1 of 5
(4,262 Views)
Hi Olivier,

The answer is No, unless LabVIEW 6.1 has added this.

Regards
Ray Farmer
Regards
Ray Farmer
Message 2 of 5
(4,262 Views)
Hi OZ,

No, it is not possible in LabVIEW 6.0.2 or lower.
I have read that it can be done in CVI and then exported to LabVIEW. If I had to guess I would probably say it was Jeane-Pierre Droilet (?sp), or Dr. Scott Hanna (?sp), or Rolf Kalbermatter (?sp) who posted a method for accomplishing this task.

If you are interested in finding out how this was done I suggest you use Brian Renken's Search engine at
http://www.searchview.net/
to find the posting (it was posted in 2000 or 2001 I think). I believe they are called "sparse enum's".

If you want to accomplish a similar functionality with pure "G" you could use a translator type sub-VI. The translator would use the use the enum value to index an array of constants that has the "Sparse-enum"s you want returned.
An advantage of this method can be realized if the translator is implemented as an action engine where the "indexed-array" is read from an un-initialized shift register. This would allow redifining the enums "on-the-fly.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 5
(4,262 Views)
Olivier;

Check Drolet's LabVIEW Bestiary. He created a very useful utility that allows you to create a G enum from a C enum statement.

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 4 of 5
(4,262 Views)
Just wanted to add that there is an easy workaround; just use a normal ring control to index an array of your arbitrary values. This may be less trouble than importing from CVI or C code.
0 Kudos
Message 5 of 5
(4,262 Views)