LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enumerated constant !

How do I define an enumerated constant with items defined for values, say, 1, 4 and18 ?
0 Kudos
Message 1 of 4
(3,213 Views)
On your block diagram, select the "enum constant" from Functions>Numeric palette. Enter your data one-at-a-time into the constant. Note: after you enter each value, you must right-click on the constant and select "Add Item After".
Good luck with it, Doug
0 Kudos
Message 2 of 4
(3,213 Views)
If you want that certain item in the enum to return a predefined specific value, that is not exactly possible. LabVIEW automatically assign 0 to the first item and then incrementing by 1 for the next items.

Check Drolet's "LabVIEW Bestiary" for a great workaround that allows you to convert a C enum into a G enum.

Enrique
www.vartortech.com
0 Kudos
Message 3 of 4
(3,213 Views)
Olivier,

Please explain in a bit more detail.

Do you want the enum to return the values in integer form of 1, 4, and 18? Are you not sure how to create an enum constant?

As indicated, an enumerated type is basically a U32 (or U16) that has pointers to the text associated with it. The output of an enum is the pointer, so it is more of a programmers tools than an input device or datatype. The reason for using them, rather than a text ring, which outputs the exact same thing, is that enums, in LabVIEW, allow the developer to produce case based code with ease, as the enum connects to cases (all basic review and you probably already knew this.)

So, if you want the values output to be 1, 4, and 18, then you need 19 items. If you want to select the ite
ms, 1, 4, and 18, then you need three items, and you will get (if you put them in order) 0, 1, 2 output respectively for each choice.

I also HIGHLY recommend creating a typedef for all enums (and clusters). This allows you to add new inputs, and makes programming a lot easier with enums.

If your question is how to create the constant, I recommend creating a new control, drop in a constant, include the items you need. Then, on your diagram, right click, and add custom, and drop in your control. When you drop a control on a diagram, it automatically becomes a constant. Alternatively, you can create a control, and change it to a constant on the diagram.

Good luck, and I hope I covered the bases
0 Kudos
Message 4 of 4
(3,213 Views)