Richard,

In my last project I opted to readjust the width of each column as 
needed.  The downside is the calculation time this requires for a 
list with many columns, but otherwise it works quite well.  Perhaps 
you can improve on my code to gain some speed (please let me know if 
you can!).  Here's what I've been doing:

on reformatTabStops
   set the itemDel to tab
   set the numberFormat to 000.##
   put the margins of fld "text" into tMargins
   put the number of lines of fld "text" into tNum
   put the number of items of line 1 of fld "text" into tItems

   repeat with i = 1 to tItems
     set cursor to busy
     repeat with x = 1 to tNum
       put (the formattedWidth of item i of line x of fld "text") & 
comma after tLengths
     end repeat
     if last char of tLengths is comma then delete last char of tLengths
     put max(tLengths) after aColWidths[item i of fld "column labels"]
     put max(aColWidths[item i of fld "column labels"]) & comma after 
tColumnWidths
     put empty into tLengths -- prep for next column
   end repeat
   delete last char of tColumnWidths -- remove final comma
   set the itemDel to comma
   put 0 into tTabStop

   repeat for each item y in tColumnWidths -- calc tabstops
     add (y + tMargins) + 2 to tTabStop
     -- 2 seems to work best, esp. for smaller sizes
     -- each tabstop = current width + prev value
     put tTabStop & comma after tTabList
   end repeat

   delete last char of tTabList -- remove final comma
   set the tabStops of fld "text" to tTabList
   set the scroll of fld "text" to 0
end reformatTabStops




>The other alternative I've played with is to use a single MC field, but to
>algorithmically truncate each line of the displated text if it exceeds the
>column width.  I found this solution to have its own issues:
>
>- Performance of the truncation bites.
>
>- Requires a monospaced font in order to calculate where to truncate,
>   or an even slower algorithm which queries the formattedwidth.
>
>- You need to maintain two sets of data, the complete set and then
>   a copy in the displayed field with some lines truncated.   Sometimes
>   this is a RAM issue, and you have to remember as you're coding that
>   everytime you touch the data you need to refresh the display version.
>
>
>So for displaying database columns, how do you folks handle that?
>
>--
>  Richard Gaskin
>  Fourth World Media Corporation
>  Multimedia Design and Development for Mac, Windows, UNIX, and the Web

-- 

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Craig Spooner
Instructional Technology Training and Development
WebCT Administrator
Office of Instructional Services
Colorado State University
(970) 491-2516

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

Reply via email to