10-18-2010 10:51 AM
Hello,
I have a text file that contains several sentences that are tab delimited:
For Example:
The cat sat on the mat. The dog sat on the cat. [Where the two sentences are delimited]
My first objective is to read these two statements into two separate text boxes… and I can do this.
My second objective is to add a line return to each statement so that when in their respective text boxes they will appear as:
The cat sat The dog sat
on the mat. on the cat.
I don’t know how to do this. Any ideas…? Ideally I want to insert something like “/n” into the sentence so that LabVIEW can interpret it as a new/return line command when it outputs it to the text box.
Kind regards,
10-18-2010 11:42 AM - edited 10-18-2010 11:45 AM
I don't know how flexible you code has to be or what are the constraints (requirements) that you need to meet.
It can range from something really simple such as finding a keyword, in this case 'sat', and simply add a carriage return after finding it.
The functions you could use are: Match Patterns & Concatenate Strings. Wire the following to the Concatenate Strings: a, bb, carriage return, c; where a,bb, c are the outputs of the Match Pattern.
Now, if you want something more sophisticated such as the ability to distinguish similar text within two (or more) sentences which may not have a known keyword, then you would have to provide the requirements for the search function and how the sentence gets split up. Can be done.
Re-read your post... What you can do to get the two split portions of text onto the same line is to first split both sentences and then concatenate them appropriately.
10-18-2010 12:15 PM
You already have separated the lines; this snippet could be a sub VI that finds the middle of the strings and inserts a Tab constant.
10-18-2010 01:19 PM
See, I wasn't sure if the exercise was to simply split the sentences in half.
I makes sense, though..
10-18-2010 01:28 PM
Three horrible things stand out in my solution:
10-18-2010 02:12 PM
10-18-2010 03:27 PM - edited 10-18-2010 03:31 PM
Here's one possible solution (note the string format display settings, LV 2010).
I use an array for the output for simplicity. You can index individual elements if really needed. 😉

First we create an array of sentences (tab is delimiter).
Then, for each sentence, we create an array of words (space delimiter)
We reshape the array of words to two rows (pad if the number of words is odd).
We form the two line sentence using array to spreadsheet string with space as delimiter.