LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I scan certain words from incoming text?

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.

Thanks,

famousmm
0 Kudos
Message 1 of 11
(4,042 Views)
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.
Message 2 of 11
(4,030 Views)
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?

Thanks,

famousmm
0 Kudos
Message 3 of 11
(4,017 Views)
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.
0 Kudos
Message 4 of 11
(4,009 Views)
Where do the token numbers 3 and 7 come from?
0 Kudos
Message 5 of 11
(4,003 Views)
I think he meant 3 and 8, the nuber being the word's place within the structured sentence (1st word is 0 based)
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 6 of 11
(3,998 Views)
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.
0 Kudos
Message 7 of 11
(3,996 Views)
Thank you sooo much! Is this the same method you would use for bigger files of text as well?
0 Kudos
Message 8 of 11
(3,992 Views)
Also, once I get the words to display on the front panel, how do I get the words to stay on the same line?
0 Kudos
Message 9 of 11
(3,988 Views)
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).
0 Kudos
Message 10 of 11
(3,986 Views)