Faster way to get tabStops?

Mike Bonner bonnmike at
Wed Feb 18 19:40:59 EST 2015

number if items not tabs. DOH.  Delimiter  on the brain.

On Wed, Feb 18, 2015 at 5:40 PM, Mike Bonner <bonnmike at> wrote:

> Ah, here.  If you're looking for the longest formatted line, you can do
> "the formattedwidth of field..." whatever.
> Then, if you're looking for the maximum number of tabs, you can cycle
> through the lines with for each, and look for the line with the most items.
>  (if the number of items in tLine > tCurrentItems then put the number of
> items in tLine into tCurrentItems)
> Does this get you close to what you want to do?
> On Wed, Feb 18, 2015 at 5:30 PM, Mike Bonner <bonnmike at> wrote:
>> The problem here is that even though you use the for each form, you are
>> still using chunking (line x of field y) to do your checks.
>> I don't know if there is a way to put the formatted text into a variable
>> in such a way that when you use "for each" you can check the formattedwidth
>> of tLine
>> Since you're cycling through every line, with your current method, using
>> "with i = 1 to the number of lines..." would work just as well and obviate
>> the need for a self run counter.
>> On Wed, Feb 18, 2015 at 4:50 PM, Dan Friedman <dan at>
>> wrote:
>>> Greetings!  I am trying to set the tabStops to fit the data a field.
>>> The script below works great!  However, ask it to process a few thousand
>>> lines with 10 or so columns, and you'll have time to get a cup of coffee!
>>> Any ideas on how to speed this up?  Maybe there is some magical property I
>>> don't about?
>>> Thanks in advance,
>>> -Dan
>>> on formatData
>>>   set the itemDel to tab
>>>   put "" into theTabs
>>>   put 0 into l
>>>   repeat for each line tLine in fld "myField"
>>>     add 1 to l
>>>     put 0 into i
>>>     repeat for each item tItem in tLine
>>>       add 1 to i
>>>       if the formattedWidth of item i of line l of fld "myField" > item
>>> i of theTabs then
>>>         put the formattedWidth of item i of line l of fld "myField" into
>>> item i of theTabs
>>>       end if
>>>     end repeat
>>>   end repeat
>>>   put "" into fTabs
>>>   put 0 into i
>>>   put 0 into tTotal
>>>   repeat for each item tItem in theTabs
>>>     add 1 to i
>>>     add tItem+20 to tTotal
>>>     put tTotal into item i of fTabs
>>>   end repeat
>>>   replace tab with "," in fTabs
>>>   set the tabStops of fld "myField" to fTabs
>>> end formatData
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:

More information about the use-livecode mailing list