07-03-2013 09:07 PM
I am not new to Labview, but this problem of converting/ faltening and unfaltening etc. in LVB always gets me.
I have a simple but basic question regarding the conversion of strings to integers, Hex numbers visa verse and so on.
For example I have characters tring, say 1234abc. I want to be able to seperate each character in it into seperate numbers or characters as the case may be, so I can use each of them seperately.
For exaple, I have a tab contorl with several panes and I want to set the property PageEnbl for all pages from a single control. So with 3 pages, if I set the control to 012, the first page will be enabled, 2nd disabled and 3rd will be disabled and greyed.
I have tried every data manipulation icon but can't seem to get this string to convert into three seperate numbers, 0, 1 and 2.
Any help to do this would be much appreciated.
Also is there is a link to a tutorial (?) on such simple conversions ? Most examples in the NI library deal with more complex things line big endian and so on.
Thanks.
Bhal Tulpule
07-04-2013 05:55 AM - edited 07-04-2013 05:56 AM
You dealing with the actual characters '1', '2'. and '3'? I would use the Scan From String inside of a While Loop. Just set the format to %1x, which will grab 1 character that can represent a hex value.
07-08-2013 07:39 AM
In select circumstances, this can be even easier. If you know that all numbers are single digit and that they are in the range 0-9, you can convert the entire string very quickly by using String to Byte Array followed by subtracting 48. String to Byte Array converts the string to an array of U8 which represent the ASCII encoding. "0" is ASCII 48, with the rest in sequence, so subtracting 48 gives you the number.