I'm trying to display information as pseudo tables in text field 
using MC2.3.1 on both Mac and Win.

I have created field with a set of tabStops and the horizontal and 
vertical grid liens are displayed.  The text in the field is in Arial 
12pt, plain, say.  What I'm trying to do is write a function that 
will truncate a chunk of text such that it is guaranteed to fit 
inside the available pixel width in any given column.

I need such a function as I want to be sure that any arbitrary text 
placed in a colunm will not overflow and cause content in the columns 
to the right to overflow.

The function I have developed so far is as follows:

function colTrimmed theText, theField, theCol
   put the tabStops of field theField into theTabs
   replace comma with tab in theTabs
   set itemDelimiter to tab
   put number of items in line 1 of field theField into maxCol
   if theCol = maxCol then
     put width of field theField - last item of theTabs into colWidthPixels
   else
     if theCol = 1 then
       put item theCol of theTabs - 1 into colWidthPixels
     else
       put item theCol of theTabs - item (theCol-1) of theTabs into 
colWidthPixels
     end if
   end if
   put colWidthPixels div (the effective textSize of field theField) 
into maxChar
   return char 1 to maxChar of theText
end colTrimmed

However, it always seems to be too conservative!  For example if the 
column can accommodate 20 chars (all "0"), it will produce a maximum 
width of 12 characters.

Any suggestions please?

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