<pre>function justify pText,pWidth  put empty into jText  put the number of lines in pText into nP  repeat with P = 1 to nP    put cutLines(line P of pText,pWidth) into vParagraph    put the number of lines in vParagraph into nL    if nL = 0 then put return after jText    else      repeat with L = 1 to nL        put nP && P && nL && L        put trim(line L of vParagraph) into vLine        if L < nL then          put the length of vLine into lineLength          if lineLength > 0 and lineLength < pWidth then            put 0 into leftCount            put the number of words in vLine into nWords            put nWords into rightCount            repeat              add 1 to leftCount              if leftCount >= nWords then put 1 into leftCount              put space after word leftCount of vLine              if the length of vLine >= pWidth then exit repeat              else                subtract 1 from rightCount                if rightCount < 2 then put nWords into rightCount                put space before word rightCount of vLine                if the length of vLine >= pWidth then                  exit repeat                end if              end if            end repeat          end if        end if        put vLine & return after jText      end repeat    end if  end repeat  hide msg  return jTextend justify</pre>