Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Conversion

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

0 Kudos
Message 1 of 3
(3,667 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(3,656 Views)

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.

0 Kudos
Message 3 of 3
(3,632 Views)