george seifert Posted April 5, 2007 Report Share Posted April 5, 2007 I've been at this LV thing for awhile now, but I must confess that I don't really understand when it's best to use an ENUM or a text ring. Text rings now seem to have the advantage of allowing nonsequential entries. Yet I find myself using ENUMs when I have a pull down list that I know doesn't have to be changed programatically. Are there any practical differences between the two? George Quote Link to comment
Tomi Maila Posted April 5, 2007 Report Share Posted April 5, 2007 QUOTE(george seifert @ Apr 4 2007, 04:43 PM) I've been at this LV thing for awhile now, but I must confess that I don't really understand when it's best to use an ENUM or a text ring. Text rings now seem to have the advantage of allowing nonsequential entries. Yet I find myself using ENUMs when I have a pull down list that I know doesn't have to be changed programatically. Are there any practical differences between the two?George Enum suits better to situations where you may want to change the order of items in enum or add and remove items from enum later on. Enum allows case structures to use the enum text as the case defining property. For example if you have an enum with elements "one", "two" and "three", you can create a case structure with cases "one", "two" and "three". If you remove "two" from the enum and delete case "two" everything still works correctly as case "three" is linked to text "three" and not to third element of the enum. Rings are just numbers attached with a text label. As such for a ring "one", "two", "three" you have to create a case structure with elements 0,1,2. If you remove "two" from the ring, then valua attached to element "three" in the ring changes from 2 to 1. This way you would need to change all your case structures to match this change. Rings however have also a benefit. When you want to create international applications, you don't want the selector value and the selector text to be tied together as they are in the case of enums. Instead you want to be able to change the text to the corresponding text in another language without breaking the code. I'd love to see a combination of enum and a ring that would have benefits of both of them. It would be like enum in all other respects but it would have separate "display string" and "value strings" for each elements. This way one could localize the display string without affecting the value string. Tomi Quote Link to comment
george seifert Posted April 5, 2007 Author Report Share Posted April 5, 2007 Thanks. That helps. George Quote Link to comment
PJM_labview Posted April 5, 2007 Report Share Posted April 5, 2007 Also, updating ring strict type def does NOT propagate to the block diagram constant by default (see this thread for more info). PJM Quote Link to comment
ned Posted April 5, 2007 Report Share Posted April 5, 2007 Rings can have any numerical representation and any set of values; enumerations must be consecutive non-negative integers. I often use rings for constants like bit masks where there may be a gap between values. Quote Link to comment
Neville D Posted April 5, 2007 Report Share Posted April 5, 2007 QUOTE(Tomi Maila @ Apr 4 2007, 06:59 AM) I'd love to see a combination of enum and a ring that would have benefits of both of them. It would be like enum in all other respects but it would have separate "display string" and "value strings" for each elements. This way one could localize the display string without affecting the value string.Tomi Try the combo box control. It allows separate display and value strings. I think it came out with LV 7.0 Neville. Quote Link to comment
Aristos Queue Posted April 5, 2007 Report Share Posted April 5, 2007 Just a warning: All of the advice I've read above is good. But you'll see a lot of VIs from NI that use rings and think "surely they should've used an enum for this!" The trouble is that enums change datatype when you change their text. That means recompiling the VIs. When we localize VIs (translate to foreign languages), we want to be able to export strings, translate, and import the strings right back into the VIs without changing functionality or needing to mass compile afterward. So we use a lot more rings than we might otherwise do. This bothers the heck out of me from time to time -- rings as block diagram constants or wired to case structures aren't nearly so useful as enums -- but various suggestions for how to improve the situation have been poor at best. Most users don't face this problem. When you write a VI, you can cleanly separate the front panel that your end user will see from the block diagram that you use internally, so you can easily follow the general rule of "use a ring on the FP, then use a single VI to translate ring values to enum values and work with the enum on the block diagram" that a lot of G developers use. But for NI, our customers are the programmers, and we have to allow for localization even of our diagrams. So we end up with rings where anyone else would use an enum. 2 Quote Link to comment
Jim Kring Posted April 5, 2007 Report Share Posted April 5, 2007 One trick that I use a lot in my UIs is to use a ring control whose strings get initialized from the strings array of an enum. I use the OpenG, "Get Enum String Values" VI to get the list of strings from the enum's type descriptor info and then pass this to the ring's Strings[] property. Quote Link to comment
shamloo Posted May 31, 2013 Report Share Posted May 31, 2013 (edited) One trick that I use a lot in my UIs is to use a ring control whose strings get initialized from the strings array of an enum. I use the OpenG, "Get Enum String Values" VI to get the list of strings from the enum's type descriptor info and then pass this to the ring's Strings[] property. Jim, where is "Get Enum String Values" VI? I googled it and tried to find it on LAVAG without success. Edited May 31, 2013 by shamloo Quote Link to comment
jcarmody Posted May 31, 2013 Report Share Posted May 31, 2013 Could it be the "Get Strings from Enum__ogtk.vi" that you're looking for? Quote Link to comment
LogMAN Posted May 31, 2013 Report Share Posted May 31, 2013 (edited) Jim, where is "Get Enum String Values" VI? I googled it and tried to find it on LAVAG without success. Refer to http://sine.ni.com/nips/cds/view/p/lang/de/nid/209027 for information about the OpenG toolkit. It includes the VI you are searching for (see jcarmodys post for a picture). An alternative option to this solution is to use the property node of the Enum directly. Configure it to return the Strings[]. Edited May 31, 2013 by LogMAN Quote Link to comment
shamloo Posted June 10, 2013 Report Share Posted June 10, 2013 (edited) Get Enum String.pngCould it be the "Get Strings from Enum__ogtk.vi" that you're looking for? Neville D told me I should have OpenG installed on my labview to be able to look for that function. Once I have install it, I can confirm what you said. By the way, I ended up changing all enums to rings to make it possible to programmatically translate the items in the control to various languages. Edited June 10, 2013 by shamloo Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.