LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Knob Text Label In Case Selector

Solved!
Go to solution

Hello forum members

 

I use a numeric control knob with text labels instead of numbers:

Zwischenablage01.jpg

For best code readability I'd like to use the text values (not the control's integer value) in a case structure as selector values directly.I could use the"Text Labels[]" or the "Digital Displays[] property, if I could cast it to a ring or enum. 

The LabVIEW help proposes :

Text Labels[] Property Dim hasPlayer, playerversion hasPlayer = false playerversion = 10 Do While playerversion > 0 On Error Resume Next hasPlayer = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & playerversion))) If hasPlayer = true Then Exit Do playerversion = playerversion - 1 Loop is_FlashVersion = playerversion is_Flash = hasPlayer

If you want to create non-sequential numeric values, use the Digital Displays[] property to get a reference to the text label display then cast the reference to the Ring class and use the Strings And Values [] property.

 

 

But I do not understand, how to perform the casting or if I am misunderstanding the help.

 

Does somebody have a suggestion?

Thanks!

Klaus

 

0 Kudos
Message 1 of 6
(5,005 Views)
The Help is referring to taking the first element of the DigitalDisplays[] property and using the To More Specific Class to cast it to a ring. However, you only need to do this if, as the Help indicates, you have non-sequential values. If the dial has sequential values (we're talking about the underlying numerical value, not the text labels) you simply need to index out from the Text Labels[] property. See attached VI (LV 8.2) that shows you this, as well as the casting.
Message Edited by smercurio_fc on 01-28-2010 09:14 AM
Message 2 of 6
(4,989 Views)

Thank you, this explains perfectly the LabVIEW help topic.

 

I believe now that it is not possible to use such a labeled dial like an enum control for feeding a case selector "by text".

 

Regards

Klaus

0 Kudos
Message 3 of 6
(4,979 Views)
I think you meant to say 'it is possible' as the posted example clearly shows.
0 Kudos
Message 4 of 6
(4,975 Views)
Solution
Accepted by topic author Klaus_M

Klaus M wrote: 

I believe now that it is not possible to use such a labeled dial like an enum control for feeding a case selector "by text".


 

Depends on what you mean by "like an enum". The text label can be wired to a case structure. You would need to manually set the case element selectors, however, for the various cases you have. You cannot dynamically create the enum, if that's what you're fishing for. You can, however, have the enum defined as a typedef and cast it.
Message Edited by smercurio_fc on 01-28-2010 10:02 AM
Download All
Message 5 of 6
(4,970 Views)

Yes, smercurio_fc, dynamically creation, that's what 've been fishing for.

I'll do it as you propose. A typedef is anyway best practice for creating maintainable and save code.

Thanks for the quick help!

Klaus

0 Kudos
Message 6 of 6
(4,951 Views)