LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

xcontrol for ring constant as enum

Is it possible to turn a ring constant to operation similiar to enum using xcontrol?  Because with enum, you can't directly program it to include a list unless you manually do it in the front panel or creating another VI and manually calling to it (very twisted method).  Just wondering if there is a way to trick a ring constant into operating like enum so that whenever I connect an xcontrolled ring constant to a case statement, I get access directly to its case string instead of numerical index?  thanks
0 Kudos
Message 1 of 4
(2,525 Views)

If you'll think about it, you'll see why this doesn't make sense - the case structure needs to have the cases assigned at *edit time*. For example, let's say you set the ring/enum at run-time to have the values "apple, orange, banana" - how do you now define which frame in the case structure handles "banana"?


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,517 Views)

the data type of teh XControl would still have to be an enum...

 

It is possible to start with a ring, write its values programajically and then right-click and do a replace with an enum. All of your strings will come across. Yes theis will NOT work if you have gaps in your number seq.

 

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 4
(2,516 Views)

You might consider just using string constants as your case selector instead of a ring or enum. There are some definite draw-backs, such as possible typo errors, but you can help account for this by creating a Default case that should never execute that simply pops up a dialog warning the developer about the typo.

 

I use strings all the time when using Queued State Machines to define the cases. To me it's easier than dealing with an enum, especially because enum array constants on a block diagram always resize to a small size when you add new enum items! This makes code quite unreadable. Smiley Mad Also, when you add a new element in a enum array constant, it defaults to the first enum value, which is visually confusing for me. Seeing an empty string pop up in the array constant is much easier on the eyes.

 

Strings will offer you the maximum flexibility, but the previous posters are still correct in asserting that the cases of the Case Structure need to be defined at edit time. You can't dynamically change these while the program runs.

 

Is your main problem with enums that using the Edit Items dialog for an enum is very slow and not user-friendly (which I agree with)? 

Message Edited by Jarrod S. on 01-26-2010 11:57 AM
Jarrod S.
National Instruments
0 Kudos
Message 4 of 4
(2,503 Views)