Page 1 of 1

the number of ACTUAL lines in a field?

Posted: Fri Mar 21, 2014 1:31 pm
by thatkeith
I know I can get the lines of a field, which tells me how many return-delimited chunks of text there are. But is there a way to determine the 'effective' lines of a field? Say I have one string with no returns in the middle, but it's long enough to linewrap into three 'effective', visual lines. (A bit like this post!) Can I find this out through scripting?

Re: the number of ACTUAL lines in a field?

Posted: Fri Mar 21, 2014 1:55 pm
by thatkeith
Replying to my own question *again*... :D

Seems that the textHeightSum tells me the total height of the lines of text in pixels. Finding the 'effective textHeight' of the field tells me the line spacing, I can work out the number of visual lines from that, with a bit of sanity checking to CMA. :wink:

Re: the number of ACTUAL lines in a field?

Posted: Fri Mar 21, 2014 1:58 pm
by dunbarx
Not sure if this will help, but look here:

http://lessons.runrev.com/s/lessons/m/2 ... -wrap-text

Re: the number of ACTUAL lines in a field?

Posted: Fri Mar 21, 2014 2:01 pm
by thatkeith
That's not quite what I was playing towards (a more accurate phrase than "working towards") but it's a great example for a related process. Thanks!

Re: the number of ACTUAL lines in a field?

Posted: Fri Mar 21, 2014 2:29 pm
by bn
Hi Keith,

isn't the formattedText what you are looking for?

Suppose you have text in a field that has it dontWrap set to false, i.e. the text wraps. You want to know how many visual lines are in the field

Code: Select all

put the formattedText of field "x" into tTemp
put the number of lines of tTemp
or I am not getting it.

Kind regards
Bernd

Re: the number of ACTUAL lines in a field?

Posted: Fri Mar 21, 2014 2:47 pm
by dunbarx
Rereading your original post (why is there always time to do that but never time to do so in the first place?) Bernd's suggestion is just what you wanted. He gets it.

Craig

Re: the number of ACTUAL lines in a field?

Posted: Sat Mar 22, 2014 5:00 pm
by thatkeith
Of course it's an easy one-liner too, no two-step process needed:

Code: Select all

put the number of lines of the formattedText of field "blurb"
Thanks!