I am trying to scan out certain words from a sentence and have LabVIEW display those words on a screen. I am having trouble getting some of the string functions to work and I can't seem to find documentation on what I need. Can someone please show me a working example in LabVIEW 7.0? Also, any extra tips or tricks would help.
There are quie a few ways to do this, you could use "search string" or "scan strings for tokens" (Check the online help for more information).
The details of the implementation will strongly depends on exactly what you want. (e.g. how to deal with duplicates, sorting of output, Should it find Tom in Tomato, etc.). The attached example shows two possible implementations.
altenbach, thanks for the great example. I actually understand it. I do have another question though. What do you do if the words you are scanning for are not always the same? For instance, you are searching for a name and age, but the name and the age will not always be the same? Everytime the program runs, you need it to find a different name and age?
Make the search words a control so you can change them at runtime. LabVIEW will not know if a word is a name or if a number is an age, you have to provide a list of possibilities one way or another.
Could it be that your string sentence is highly structured, e.g. always "My name is %name and my age is %number"). In this case, you would extract token #3 and #7.
Scan strings for tokens gets succesive words if used in a loop with the offset fed by a shift register as attached.
In this particular case, you look for words #3 and #8 (sorry, not 7, I counted wrong earlier). The attached VI gets the third and eight word in the sentence.
If you want all words to stay on one line, replace the newline character with e.g. a single space character in the concatenate array tool (inside the case structure).