ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parse string into array for comparison

Hi All,

 

I am trying to parse a string message into an array of numbers so I can check if my event was successful.

 

\FF\FE\01\FD\02\00\00\00

 

I know I just need to read through and discard the \, but I don't know how to do that in Labview. I just need to check if the 6th byte = 00 or not.

 

Thanks! I mostly need help with parsing in labview.

0 Kudos
Message 1 of 9
(4,506 Views)
right click on the string and click the slash code.
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 9
(4,497 Views)
I would use the spreadsheet string to array vi with "\" as the delimeter and convert to unsigned bytes.  See example.
0 Kudos
Message 3 of 9
(4,493 Views)

Assuming this is a plain ASCII string containing the letters 0..F and "\" as delimiter, you can simply used "Spreadsheet string to array" with the following settings:

 

Type= 1D U8 array

format= %x

delimiter= "\"

 

 

 

One problem is the extra delimiter at the beginning, so use array subset to skip the first element.

 

(EDIT: Ahh, Darin beat me with a similar solution. Mine's a little easier ;)).

 

 

Message Edited by altenbach on 08-06-2009 04:30 PM
Message 4 of 9
(4,491 Views)

altenbach wrote:

(EDIT: Ahh, Darin beat me with a similar solution. Mine's a little easier).



I was expecting you to have some byte-swapping, type-casting, hex-code-displaying, quick-dropping action that would somehow manage to do it in a single step. 

Message Edited by Darin.K on 08-06-2009 07:40 PM
Message 5 of 9
(4,463 Views)
Well, technically, the original question was

amita wrote: I just need to check if the 6th byte = 00 or not.

Thus, you could simply just do this:

 Smiley Wink

Message Edited by smercurio_fc on 08-07-2009 10:11 AM
0 Kudos
Message 6 of 9
(4,419 Views)
Well, I did not read that far.... 😮
0 Kudos
Message 7 of 9
(4,411 Views)

amita wrote: I just need to check if the 6th byte = 00 or not.

Here's yet another variation... 😉

 

Message Edited by altenbach on 08-07-2009 04:59 PM
0 Kudos
Message 8 of 9
(4,387 Views)

amita wrote:

Thanks! I mostly need help with parsing in labview.


Parsing the question is almost as much fun as answering it.Smiley Happy    I originally considered this solution as a more general demonstration of parsing strings in LV.  When I have a (complex) string to parse I often use 'Scan String for Tokens'  as shown in this example.  Not much harder than the other solutions and no need to deal with the issue of the leading '\'.  I think we still need a Rube Golderg solution as well as an obfuscated version.
0 Kudos
Message 9 of 9
(4,377 Views)