LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use a hex string with a case statement?

Solved!
Go to solution

Simple question:

Can i input a hex string to a case statment and have the case statement see it as hex?

 

I understand that i could convert the hex string to a number then input the hex number to the case statement but i'm curious if i could have the case see the string itself as hex without this added function.

 

Not having to convert all of my strings to numbers all throughout my code would be nice 😉

 

Thanks

 

-Eric

0 Kudos
Message 1 of 5
(3,566 Views)
Yes you can. Wire an integer to the selector node, the right click on the case label. Down near the bottom is a selector for choosing the radix.

Mike..

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 5
(3,561 Views)
Solution
Accepted by topic author EricBSEE

How long are the strings? Since you talk about converting to numbers, they are probably short and all of equal lenght.

 

How many different possible strings are there?

 

The case header understands \-codes in the case of a string case selector label, so this should be sufficient for your purpose. For example this code will light up the LED (...while wiring a plain string of "\00\00" would not!)

 

 

(See also the last sentence in the "enumerated values" section of the help).

 

 

 

0 Kudos
Message 3 of 5
(3,539 Views)

Thanks altenbach,

 

Looked at the "backslash codes" for case statemetns and see that adding the "\" allows the case to see my string as hex instead of ascii.

 

The only reason that i didn't want to change all of my strings to numbers is laziness on my part. I realized that there are now 15 different locations in my code where i have hex data strings going into case statements and real estate on my screen is minimal so i'm having a hard time cramming more functions in without resizing everything. (I am making changes to a large existing code i wrote years ago)

 

One more question though.

After adding the "\" before my number is working great, but the case statement is showing the ascii value of my entered hex. (I type "\3F" but the case statement shows "?")

Again, the code works, but is there a way to get it to show me the hex value instead of the ascii value?

 

                                                                                                    hex string.png

0 Kudos
Message 4 of 5
(3,482 Views)

@EricBSEE wrote:

Again, the code works, but is there a way to get it to show me the hex value instead of the ascii value?


Unfortunately no. String are only displayed as \-codes.

 

I think it would be a good idea to also support other string display formats, so that would a an idea to submit to the ideas excahnge. Maybe it already exists, haven't looked yet.

0 Kudos
Message 5 of 5
(3,456 Views)