LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to turn a string sentence into words with indicators?

Hi everyone!

I am creating a command analysising program in LabVIEW 7.0.
I want to know how to turn a string sentence into words?

Such as:
Turn "I am a LabVIEW beginner" into "I", "am", "a", "LabVIEW" & "beginner" five indicators.

What should I do???
0 Kudos
Message 1 of 16
(4,326 Views)
Just search for the delimiter (in the sentence given a "space"-character).

Have a look at this simple example.

Hope it helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 2 of 16
(4,308 Views)
Hi,

A very simple way is to use the "scan from string function" in a loop with "%s" as a constant in the "format string" input.
This will take each word, you just have to put them in an array indexed by the loop.
The ending condition of the loop will be when the input sentence is "empty of words".
Don't forget to put a shift register for the input sentence, or it will take the first word at each iteration and will never stop!

I joined a picture of the code and front panel.

Best regards,
G Liagre
Best regards,
G Liagre
0 Kudos
Message 3 of 16
(4,307 Views)
Hi becktho!
Thank you for your reply!

I would like to know the function of "delimiter" in your program.
When I changed the input value of it.
Some bugs came out.

What is it?
0 Kudos
Message 4 of 16
(4,302 Views)
Hi G Liagre!
Thank you for your reply!

If I don't want the output indicator is an array indicator, just some string indicators are okay,
what should I do?

Besides, if the input string is empty, there is some problem on the " Scan from string".
How can I solve it?
0 Kudos
Message 5 of 16
(4,299 Views)
Hi G Liagre!
Thank you for your reply!

If I don't want the output indicator is an array indicator, just some string indicators are okay,
what should I do?

Besides, if the input string is empty, there is some problem on the " Scan from string".
How can I solve it?
0 Kudos
Message 6 of 16
(4,299 Views)
Hi

The yellow string-function is the "Match Pattern" function.

The delimiter is the string that separates your words. So if you enter a "x" it won't work anymore, because your words are separated with a space-character.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 7 of 16
(4,297 Views)
You can add at the end of the loop an array indexing and put each value of the array in a simple string.
But you need to know the number of word you enter before you do your program.
I don't think it's possible to programmatially create an indicator.

See the modifications I made in the picture

Best Regards,
G Liagre
Best regards,
G Liagre
0 Kudos
Message 8 of 16
(4,294 Views)
If you are not working with fixed length "command sentences" you won't know how many string indicators to have. Even if LabVIEW allowed you to programmatically create them (string indicators) you wouldn't be able to wire them to the connector pane to pass their values to other VI's. If you, as the earlier post mentions, place them into an array of string indicators, it can then easily be passed to the calling VI, where you can parse the commands, either by referencing a specific location in the array (i.e.:element 2 is the third word in the command sentence)or by other tools (search 1D array for instance). This technique of parsing a command string into an array and then looking a specific elements of the array is exactly what I have done in one of my recent projects to allow me to use a text "script" to determine what functions will occur and when in the execution of my program. If you use commas (,) or the TAB charecter as your delimiter it also allows you to easily read and edit the text file with a spreadsheet program, like Excel.
Placing them into a string array would also allow you to flexibly display them on the UI, as you can programmatically change how the array is displayed, or even wire the array into a table display.

Good luck,


Putnam Monroe
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 9 of 16
(4,272 Views)
Hi becktho!
Thank you for your reply!

Now I get more ideas from the delimiter.

Thank you very much!
0 Kudos
Message 10 of 16
(4,260 Views)