LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interpret Line Returns in a text box

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,

  

0 Kudos
Message 1 of 7
(3,802 Views)

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.

0 Kudos
Message 2 of 7
(3,790 Views)

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.

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 7
(3,782 Views)

See, I wasn't sure if the exercise was to simply split the sentences in half.

I makes sense, though..

0 Kudos
Message 4 of 7
(3,770 Views)

Three horrible things stand out in my solution:

 

  • I inserted a Tab instead of a line feed
  • It shouldn't leave a space at the end of the first line or the beginning of the second (mine did)
  • It doesn't do anything to prevent splitting the sentence in the middle of a word (I got lucky, but it should be fixed)
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 7
(3,763 Views)

split string.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 7
(3,753 Views)

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.

0 Kudos
Message 7 of 7
(3,742 Views)