LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan String Token Problem with leading Tokens

Solved!
Go to solution

Hi, I'm using the scan string for token to read in a string of tokens that contain a leading "*" char in front of each string and terminates when the token index = -2. This works great if I have say *12345*1234 and so forth, but if there is bad data, say 1234 without the leading "*" in front, the token index return value is still -1 and it returns data which I read in thinking it found the "*". Maybe I shouldn't use the string for token function since it's probably just designed for ending tokens and not data with leading tokens. Is there a way to make this work properly or should I use another method to search for leading tokens in a string?

 

Thanks.

 

 

 

0 Kudos
Message 1 of 14
(4,386 Views)

Here is the example that describes the problem above with leading tokens 😃

0 Kudos
Message 2 of 14
(4,381 Views)

You should consider using the Spreadsheet String to Array.  Just use * as the delimiter.  You will have to remove the first element, but I think it will get you to where you want it.


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 3 of 14
(4,366 Views)

yes.png

 

 

This vi should do what you want and will not error with or without a Leading token.  The "\*" looks for a litteral "*" rather than a repeat of "\" (That would be "\\*") Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 14
(4,364 Views)

@crossrulz wrote:

You should consider using the Spreadsheet String to Array.  Just use * as the delimiter.  You will have to remove the first element, but I think it will get you to where you want it.


(Don't you need to escape that *) Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 14
(4,361 Views)

Jeff, I really like your approach, but every time I run the example it returns the data starting in array offset 1 and not 0, why would that be?

0 Kudos
Message 6 of 14
(4,358 Views)
Solution
Accepted by topic author QRP

Here.  Try this one.  It does the same thing and uses exposed functions.

 

The string functions look for something to mark the end of a string.  All languages that I know of do this.  So, like I said, remove the first element.  I recommend the Subarray function with the index set to 1 and length unwired.

 


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 7 of 14
(4,349 Views)

I think for some reason all of this stuff is setup for ending delimitors even the spread sheet to string function. There has to be a way for Labview to be able to handle in coming serial traffic with leading tokens. I sure miss my C programming language, it's so simple that way 😃

0 Kudos
Message 8 of 14
(4,347 Views)

@JÞB wrote:

@crossrulz wrote:

You should consider using the Spreadsheet String to Array.  Just use * as the delimiter.  You will have to remove the first element, but I think it will get you to where you want it.


(Don't you need to escape that *) Smiley Wink


That's probably how ForImStuck got into his predicament. Smiley LOL

 

But, no.  The spreadsheet string to array doesn't use that capability.  Probably because that is only used with file functions.


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
Message 9 of 14
(4,339 Views)

Jeff you are the master my friend. Your last example worked wonderful. Thank you so much!

0 Kudos
Message 10 of 14
(4,337 Views)