Dynamic tabStops (enhanced)
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Fri Jan 13 12:46:01 EST 2006
Hi again Roger,
Below a version easier to understand I have commented and slightly
modified :-)
The single parameter is the short name of the field.
on SetTabStops pFld
local tNumOfLines,tNumOfItems = 0,tTabStopsList
constant kPixelsAdded = 10 -- adjust this value as wanted
----- intialization:
-- number of columns (works even if the number of items is not the
same in all lines)
set the itemDel to tab
repeat for each line tLine in fld pFld
put max(the number of items of tLine,tNumOfItems) into tNumOfItems
end repeat
put the number of lines of fld pFld into tNumOfLines
-- creating variables (as many as columns):
repeat with i = 0 to tNumOfItems
do "put 0 into r" & i
end repeat
----- getting the wider item for each column:
repeat with i = 1 to tNumOfLines
repeat with j = 1 to tNumOfItems
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 & ") + kPixelsAdded into r" & j
end repeat
end repeat
----- building the right values (ts2 = ts1 + ts2, etc.):
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
----- building the tab stops list:
repeat with i = 1 to tNumOfItems
do "put r" & i && "after tTabStopsList"
put comma after tTabStopsList
end repeat
put 10000 after tTabStopsList
-- to throw away the last vertical bar if vertical bars are displayed
set the tabstops of fld pFld to tTabStopsList
end SetTabStops
> 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?
Best Regards from Paris,
Eric Chatonet
------------------------------------------------------------------------
----------------------
http://www.sosmartsoftware.com/ eric.chatonet at sosmartsoftware.com/
More information about the use-livecode
mailing list