LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formatting an enum into a string

Ok, This isn't actually a question, but I just found out something which i simply did not know up until now.

When parsing a string using the "Format into string", you can get the strings associated with an enum by simply connecting the enum to an input field formatted with %s. I seriously never knew that, and didn't actually think it would work.

I thought I'd post just in case any other self-taught LVers could find this interesting.

The following text is actually in the LV help for the formatting specifier syntax
"
Notice that you can use either a numeric or string conversion code with an enumerated type or Boolean type, depending on whether you want the numeric value or symbolic (string) value of the enumerated type.
"

So this actually also works for booleans (String output is TRUE or FALSE).

So basically, shame on me for not knowing this. 😞

Maybe a LV course would finally make sense?

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 1 of 6
(3,815 Views)
Cool, I didn't know that either.
Then again, I don't think I ever really had use for this.
this is what you get when you don't RTFM.
In our defense, though, there are many functions in LV and reading the help for each of them (even the common ones) can be hard.

___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(3,811 Views)
Thanks thats exactly what I was looking for.
---------------------------------
[will work for kudos]
0 Kudos
Message 3 of 6
(3,368 Views)

rex1030 wrote:
Thanks thats exactly what I was looking for.

Tip: With newer versions of LabVIEW you can leave out the %s alltogether. Smiley Wink

0 Kudos
Message 4 of 6
(3,360 Views)
I didn't know this worked on booleans. Thanks for the tip.
Message Edited by Broken Arrow on 12-02-2009 03:35 PM
Richard






Message 5 of 6
(3,346 Views)

Broken Arrow a écrit:
I didn't know this worked on booleans. Thanks for the tip.

 

Same for me. I have used it for many years with enums but it never came to my mind to use it with booleans !

Message 6 of 6
(3,301 Views)