LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to convert a series of numbers and strings into a hex formatted string

but when I am finished putting all the elements together the format isn't right. For example I get "02310233E14003" instead of "0231 0233 E140 03".
0 Kudos
Message 1 of 7
(2,899 Views)
If you need spaces every four characters, the easiest way to do so would be to manually insert them. I.e. convert your string into an array of U8 (there's a function that does this already in LV), feed it into a for loop using auto indexing, and every fourth iteration insert a space into the array. Then convert it back to a string and there is your formatted string.
0 Kudos
Message 2 of 7
(2,893 Views)
But there really aren't spaces there its to a hex display format that I need to send to the device. It won't accept a hex string.
0 Kudos
Message 3 of 7
(2,883 Views)
What exactly do you need to send to the device? In other words, do you need to convert the numbers and strings into their ASCII values, or are you trying to send values as a binary encoded string?
 
If you need to flatten things to a string (i.e. make them hexadecimal), you can use the "Flatten to string" VI.
 
If you need to turn the hexadecimal number into a string, you can use the "Format into string" VI.
 
Perhaps some more information would be helpful to solve your problem?
0 Kudos
Message 4 of 7
(2,881 Views)
I'll try that and see how it works (flatten string.vi). Thanks
0 Kudos
Message 5 of 7
(2,878 Views)

Check out this link, which explains how to do it and has sample vi's to try:

http://forums.ni.com/ni/board/message?board.id=170&message.id=121688&query.id=0#M121688

You may also want to try (or look at) the function "String to Byte Array" which is located at the: Functions>>Numeric>>Conversions palette.

JLV

Message Edited by JoeLabView on 07-19-2005 04:04 PM

Message 6 of 7
(2,867 Views)
Not sure if the attached is what you are looking for.
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 7 of 7
(2,846 Views)