LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

end of string characters

Hi,

I am parsing a string and want my loop to stop right at the end of the string. Is there an end of string character or do I keep having my program run until it reads an empty string character and then stop it.

Thank you

0 Kudos
Message 1 of 7
(5,589 Views)
There is no such thing as an "empty string character". An empty string is lenght zero. 😉
 
You are probably leaving out important information. Is it possible that you have an array of strings? How does the loop work? Several string parsing finction let you know when the end of the string has been reached, so how are you parsing the string?
 
In any case, the index of the last character of any string is easy to find, just use the "string length" function (minus one).
 
Please provide more information, maybe even attach a small example program.
Message 2 of 7
(5,585 Views)
I would attach my vi but it contains many subvis in it and it also requires some files in order to run. However, which string function are refering to that tells when the end of string is reached.

Thank you
0 Kudos
Message 3 of 7
(5,583 Views)

As Altenbach mentioned, use the String Length function to get the length of the string.  The last character is at String Length - 1.  So you can wire the output of String Length into a for loop N terminal.  Inside the loop, you would have to extract each character one at a time using String Subset.  See picture:

In the False case, just wire the numeric terminal straight through.

Message Edited by tbob on 10-20-2006 05:08 PM

- tbob

Inventor of the WORM Global
Message 4 of 7
(5,569 Views)
"Match pattern", "Match regular expression", "Scan strings for tokens", etc. all  gives you an output of -1 on one of the terminals if the end of the string has been reached (terminal "offset past match/token").
 
 
Message 5 of 7
(5,567 Views)
Hi,

Thank you for your earlier suggestions. In this case I can't use a for loop because I am not reading in one character at a time. The loop will read a different amount of characters for each loop iteration depending upon certain conditions determined by using case structures. Also, if I use match string functions, I need to match for certain characters, but I don't have anything I will want to match against in this case.


0 Kudos
Message 6 of 7
(5,561 Views)
If you can't use a for loop, use a while loop and check to see if the last character you read has an index equal to the String Length - 1.  Use this to stop the loop.  An alternative would be to concatenate a NULL character (Hex 00) to the end of the string before you start to process it.  Then look for this NULL when processing to signal a stop.  Remove the NULL when done.
- tbob

Inventor of the WORM Global
Message 7 of 7
(5,556 Views)