Dynamic tabStops

Eric Chatonet eric.chatonet at sosmartsoftware.com
Fri Jan 13 12:22:13 EST 2006


Hi Roger,

Here is a handler I use.
No matter with the number of columns: the whole thing is fully  
automated.
The process assumes there is a hidden field named "Template" that is  
used to get the formattedWidth and takes into account different  
styles if there are any.
Note that the handler uses intensively the do command: good handler  
to learn how to master this command ;-)
For instance: to initialize as many variables as needed.


on SetTabStops pFld
   local tNumOfItems,tTabStopsList
   -----
   set the itemDel to tab
   put the number of items of line 1 of fld pFld into tNumOfItems
   repeat with i = 0 to tNumOfItems
     do "put 0 into r" & i
   end repeat
   -----
   repeat with i = 1 to the number of lines of fld pFld
     repeat with j = 1 to the number of items of line 1 of fld pFld
       set the htmlText of fld "Template" to the htmlText of item j  
of line i of fld pFld
       do "put max(r" & j & comma & "the formattedWidth of line 1 of  
fld" && quote & "Template" & quote & ") + 10 into r" & j
     end repeat
   end repeat
   -----
   repeat with i = tNumOfItems down to 2
     repeat with j = i down to 2
       do "add r" & j - 1 && "to r" & i
     end repeat
   end repeat
   -----
   repeat with i = 1 to tNumOfItems
     do "put r" & i && "after tTabStopsList"
     put comma after tTabStopsList
   end repeat
   put 10000 after tTabStopsList
   set the tabstops of fld pFld to tTabStopsList
end SetTabStops

Take care of carriage returns!

Best Regards from Paris,
Eric Chatonet

Le 13 janv. 06 à 16:41, Roger.E.Eller at sealedair.com a écrit :

> I need a table field to auto-resize to fit the tab-delimited  
> content. What
> is a good method for growing/shrinking the tabStops to fit the longest
> text of each item of a field?

------------------------------------------------------------------------ 
----------------------
http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/





More information about the use-livecode mailing list