>A script can't use the textheight to determine the width of a string.
>Even with monspaced fonts, there is no relationship between the width of
>the character letters and the textsize, and even worse, the textsize
>will vary from font to font, and from platform to platform. Luckily
>MetaCard has a "formattedwidth" property that lets the script determine
>the actual width of a string in pixels.
>
>This seems to work:
>
>on insertItem theText, theField, theCol
>   put "1," & the tabstops of fld theField & comma & the width of fld
>theField into theTabStops
>   put (item theCol+1 of theTabStops) - (item theCol of theTabStops) 
>into thePixelWidth
>   set itemdelimiter to tab
>   repeat for each char i in theText
>     put i after temp
>     put temp into item theCol of fld theField
>     select item theCol of fld theField
>     if the formattedwidth of the selectedchunk >= thePixelWidth-10 then
>-- 10 pixels for a margin; adjust
>       delete last char of item theCol of fld theField
>       exit repeat
>     end if
>   end repeat
>end insertItem
>
>This script assumes that the field has no tab stops that extend past its
>right edge. If it does, you'll have to change the way the last column's
>width is calculated. You'll also probably want to lock the screen while
>this runs.
>
>--
>Jacqueline Landman Gay        |             [EMAIL PROTECTED]

Thanks Jacqueline, I'll give it a try.

Cheers
Peter
-- 
--------------------------------------------------------
Peter Reid
Reid-IT Limited, Loughborough, Leics., UK
Tel: +44 (0)1509 268843 Fax: +44 (0)870 052 7576
E-mail: [EMAIL PROTECTED]
Web: http://www.reidit.co.uk

Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to