LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

12 characters Truncation for Display

Solved!
Go to solution

Hi,

I am trying fit user generated text strings on to a 6*12 display so I have to read in what the user typed and then format it for the display for e.g

 

 

'Totally random text string'

 

 

Totally/s/s/s/s/s   = 7+5 spaces=12

 

6+6 spaces

Random/s/s/s/s/s/s/s

 

11+1 space

text string/s

 

Has anyone done this before or something similar so I can get my head around the concept? Thanks

0 Kudos
Message 1 of 10
(5,392 Views)

Hi Jim,

 

very basic and straight forward:

check.png

 

A little bit more advanced:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(5,383 Views)
Solution
Accepted by JimKay

I think this is more what OP was looking for. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 10
(5,368 Views)

Hi Guys,

Thanks for the replies yes Ger its a bit more complex than that..

Yamaeda I cant open that vi due to running 8.5..

When reading the words in decision needs to be made about the next word..will it fit in the 12chars with another word or must it be padded..As the input is entered by the user its varaible but I could limit to no words larger than 12 chars

Heres what I have so far attached

 

 

 

0 Kudos
Message 4 of 10
(5,361 Views)

Yamaeda's VI saved for LV 8.5

0 Kudos
Message 5 of 10
(5,351 Views)

Ah brillant stuff ..I would have got there myself in about 10 years..lol.

Thanks everyone!

0 Kudos
Message 6 of 10
(5,342 Views)

Please mark the solution post. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 10
(5,333 Views)

Simple greedy word wrap seems like something regexable.

 

WordWrapRegex.png

Message 8 of 10
(5,327 Views)

Man, Regexp is really hard to decipher. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 10
(5,289 Views)

Could still be some corner cases since I kind of wrote this literally.

 

(.{1,%d})( +|$\\n?)|(.{1,%1$d})

 

consists of three capturing groups, the match is either the first two OR the third one

 

first: (.{1,N})  The %d is replaced with the width so this captures from 1 to N characters which are not newlines

 

second : ( +|$\n?) [extra \ is from string display] capture 1 or more spaces (there is a space before the +) OR end of the line with optional newline.  Had to make newline optional to handle 1 line strings such as this one.  (that is a hard one to catch at first)

 

third: (.{1,N}) grab the first N non-newline characters

 

First choice is to match 1 to N characters which are followed by spaces, the end of the string or newline.  This is greedy so it gets the longest possible match. 

If the first choice fails, you simply grab the first N characters

 

Replace:  Here is another one of my favorite tricks.  There are two capture groups we care about either #1 or #3.  One will match, the other is empty and we want to replace with the one that matched.  If you replace one followed by the other ($1$3) then either way you get the string that matched.  Simply add a newline to do the word wrapping.  Hard part is to remember to start counting at 1.

 

0 Kudos
Message 10 of 10
(5,283 Views)