04-13-2015 03:24 PM
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
Solved! Go to Solution.
04-13-2015 03:33 PM
04-13-2015 04:12 PM - edited 04-13-2015 04:20 PM
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).
04-14-2015 07:48 AM
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?
04-14-2015 10:05 AM
@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.