09-28-2012 10:37 AM
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.
Solved! Go to Solution.
09-28-2012 10:41 AM - edited 09-28-2012 10:48 AM
Here is the example that describes the problem above with leading tokens 😃
09-28-2012 10:53 AM
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.
09-28-2012 10:55 AM
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 "\\*")
09-28-2012 10:57 AM
@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 *)
09-28-2012 11:06 AM
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?
09-28-2012 11:13 AM - edited 09-28-2012 11:14 AM
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.
09-28-2012 11:14 AM
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 😃
09-28-2012 11:16 AM
@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 *)
That's probably how ForImStuck got into his predicament.
But, no. The spreadsheet string to array doesn't use that capability. Probably because that is only used with file functions.
09-28-2012 11:18 AM
Jeff you are the master my friend. Your last example worked wonderful. Thank you so much!