function to calculate string length...

Wouter wouter.abraham at scarlet.be
Mon Jan 3 20:51:53 EST 2005


On 29 Dec 2004, at 18:00, metacard-request at lists.runrev.com wrote:

> Message: 1
> Date: Tue, 28 Dec 2004 20:08:02 -0800
> From: Chipp Walters <chipp at chipp.com>
> Subject: Re: function to calculate string length...
> To: Discussions on Metacard <metacard at lists.runrev.com>
> Message-ID: <41D22DA2.1080006 at chipp.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Thanks for this, would you mind explaining what it does?
>
> Thanks again
> Chipp

Chipp, sorry for the delayed response due to festivities.
My other handler is using the difference in number of lines of a field 
and the number of lines of the formattedtext of the same field if the 
text is "wrapped". And it is useless if the words in the list field are 
very long and the width of the field is very small (as it uses the word 
wrap done by the engine).
Hugh also pointed out that the character used for the ellipsis is 
differently mapped in windows and mac.
Mac uses the numtochar(201) while windows uses numtochar(133) 
(according to Hugh).
So back to the use of the normal 3 points and optimizing your original 
handler.
May be you did it already this way then disregard this one.

on formatFld pFldID
   put 20 into fineTune  ### adjust to taste
   put (the width of fld id pFldID) - fineTune - scrollbarwidth of fld 
id pFldID into tW
   repeat with i = 1 to the num of lines in fld id pFldID
     repeat with y = 1 to the num of chars in line i of fld id pFldID
       if the formattedwidth of char 1 to y of line i of fld id pFldID 
 >= tW then
         put char 1 to y - 1 of line i of fld id pFldID & "..." & cr 
after tList
         exit repeat
       else if y = the num of chars in line i of fld id pFldID then
         put line i of fld id pFldID & cr after tList
         exit repeat
       end if
     end repeat
   end repeat
   put tList into fld id pFldID
  end formatFld

(beware of the mail-linewraps)
Greetings,
WA



More information about the metacard mailing list