LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parse string by length

I have a incoming data string that is Hex, which is comprised of messages that have a string length of 98 characters (no delimiters).  How do I got about parsign this these strings?  I've tried to use something like a match regular expression, or a scan from string, inside a while loop.  Offsetting the incoming string by 98 characters, trying to read a formatted string (%98s), then building an array of the found messages, until I have reached the end of the string.  But I am unable to get this approach to work properly.
0 Kudos
Message 1 of 5
(2,837 Views)

How about a loop that spits the string at the 98th character.  This attached picture shows a loop that will create an array of strings with each element (except possibly the last one) is 98 elements in size.

Message Edited by paulmw on 10-20-2006 12:51 PM

0 Kudos
Message 2 of 5
(2,829 Views)
Thanks for the response.  I actually just figured it out.  I had the right loop and everything but for some reason the 'scan from string.vi' wasn't working the way I was planning.  Even though the formatted string I was using was (%98s), which should extract strings of length 98, it wasn't.  I called NI, they weren't sure why it wasn't working either.
 
However, the 'string subset.vi' works fine.  I'm just upset that I spent time trying to get something so simple to work.
0 Kudos
Message 3 of 5
(2,817 Views)


@systems_eng wrote:

"I'm just upset that I spent time trying to get something so simple to work."




If I had a nickel for every time I said this I'd retire quite wealthy... Smiley Very Happy
0 Kudos
Message 4 of 5
(2,816 Views)
By the way, a possible reason the Scan From String wasn't working as expected for you is that the string contained characters which causes the function to stop reading at that point. Examples are the newline character, tab character, etc. Basically characters that are whitespace. So, if the 39th character in your string was the newline character (0x0A), the Scan From String would only return 38 characters.
0 Kudos
Message 5 of 5
(2,804 Views)