From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking For Property On String Which Returns Displayed String Text

Solved!
Go to solution

Terrible title I know but I didn't know how to shorten it.  So set say I have a string control with some text in it.  If the text is too long it will wrap onto a new line which is great.  But lets say I want to know what that text looks like in the control.  I want to know how many lines are displayed, and what the text is, preferable with return characters inserted.  Here is an image of how I would want the text to be returned:

 

Example_VI_FP.png

The added kicker is I would like this to work on Linux RT hardware too.  This means currently using a subset of UI properties and methods.

0 Kudos
Message 1 of 6
(2,920 Views)

Even with all the scripting/secret nodes enabled I dont see anything that would get you what you want..Have you considered using the get text rect function and manually figuring it out? Or do you need it exact?

0 Kudos
Message 2 of 6
(2,907 Views)
Solution
Accepted by topic author Hooovahh

Okay, what about using the 'Get Nth' line method? Put it in a loop (loop index to index - the function returns an error when the line doesnt exist which you can use to stop the search)and you can build up what the string looks like from there.

Message 3 of 6
(2,896 Views)

I don't know about all the other stuff you want but the Text.Text property will return the text and then the length can be determined the usual way, same for showing the control characters.

 

ttCapture.PNG 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 6
(2,890 Views)

I once solved the inverse problem, making a String Control "fit" a single-line string, regardless of the String's Font settings, so I can make some suggestions:

  • The String Properties allow you lots of leeway.  Start by setting the "Wrap" property to "True" (to give you a multi-line string).
  • The Method "Get Nth Line" will (surprise!) give you the contents of the Nth line, including the Text and Start and End offsets of the Line in the Original String.  Note that if you have a 3-line String and you ask for Index = 3 (the 4th line), Start will be 0.
  • I'm not sure how wrapping structures the placement of EOL characters, but that should be easy to figure out (and I know you know how to "do the experiment").

Bob Schor

Message 5 of 6
(2,876 Views)

K guys thanks, this was actually pretty easy.  For some reason I didn't realize the Nth line string worked on the control, I figured it functioned the same as the Pick Line primitive.  And bonus it does work on RT (at least my Linux RT with embedded UI enabled)

0 Kudos
Message 6 of 6
(2,845 Views)