取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 7 条)
5,873 次查看
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.
2 条消息(共 7 条)
5,869 次查看
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 项奖励
3 条消息(共 7 条)
5,867 次查看

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
4 条消息(共 7 条)
5,853 次查看
"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").
 
 
5 条消息(共 7 条)
5,851 次查看
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 项奖励
6 条消息(共 7 条)
5,845 次查看
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
7 条消息(共 7 条)
5,840 次查看