2 Replies Latest reply on Dec 1, 2006 3:07 AM by duckets

    Problem formatting text field

    Level 7
      Hi everybody.

      I have a text field that allows the user to input notes about a project and
      then print it using Mprint. Bringing that field over into Mprint makes the
      line exceed past the margins if it is too long.... soooo... what I am trying
      to do is this:

      Create lingo that will look at the text field and put a RETURN after X
      amount of characters that fit per lines...let's say 75.

      So every 75 lines it would start a new line. Does this make sense?

      Any help would be greatly appreciated!


        • 1. Re: Problem formatting text field
          Level 7
          If you mean you just want to put a return after every 75th character of
          a text member, then this will do (This assumes that the text itself is
          in a member called "textMember"):

          on addReturns me

          --put the text into a variable

          --run through all characters and put in the return where needed
          repeat with i= tempText.char.count down to 1
          if i mod 75=0 then
          put return after tempText.char
          end if
          end repeat

          --put the new stuff back into the text member
          • 2. Re: Problem formatting text field
            duckets Level 1
            Putting a return after a fixed number of characters would assume that your characters are all the same width. Unless you're using a mono-spaced font (such as Courier New), they won't be.

            Probably what you want to do is scan through each character of the text member, and use the 'charPosToLoc()' function to check the actual pixel position of each character.

            When the loch value returned is greater than your page width in pixels, insert a return character at that point, and continue processing the next line.

            hope this helps!

            - Ben