Text Flow

BNig bernd.niggemann at uni-wh.de
Wed Sep 16 03:39:14 EDT 2015

Hi Charles,

I gave this a try with 4 fields. 
Field "source" contains the whole text
Then there are 3 identical output fields fOut1, fOut2, fOut3
these three output field all have the same height and width and textHeight.
And textHeight is fixed.

The trick is to use formattedText -> see dictionary.
I put the whole text into field fOut1 so it formats to the dimensions of
field fOut1.
Then I take the formattedText of field fOut1 and get the text return
delimited at the apparent line endings.
>From there I calculate the number of words for the height of the field since
number of words are not changed by the additional return in the
formattedText. I put those into field fOut1 and then the other two fields.

If your fields differ in dimensions or textHeight you would have to change
the code accordingly.

on mouseUp
   put "fOut1,fOut2,fOut3" into tFields
   put field "source" into tData
   put the height of field "fOut1" into tHeight
   put the effective textHeight of field "fOut1" into tTextHeight
   lock screen
   put tData into field "fOut1"
   put the formattedText of field "fOut1" into tFormatText
   put tHeight div tTextHeight into tPossibleLines
   put 1 into tFirstLine
   put tPossibleLines into tLastLine
   put 0 into tWordsUsed
   repeat with i = 1 to the number of items of tFields
      put item i of tFields into tName
      put the number of words of line tFirstLine to tLastLIne of tFormatText
into tMaxWords
      put word tWordsUsed + 1 to tWordsUsed + tMaxWords of tFormatText into
field tName
      add tMaxWords to tWordsUsed
      add tPossibleLines to tFirstLine
      add tPossibleLines to tLastLIne
   end repeat
   unlock screen
end mouseUp

Kind regards

View this message in context: http://runtime-revolution.278305.n4.nabble.com/Text-Flow-tp4696328p4696332.html
Sent from the Revolution - User mailing list archive at Nabble.com.

More information about the use-livecode mailing list