Faster way to get tabStops?

Dan Friedman dan at clearvisiontech.com
Thu Feb 19 00:50:19 CET 2015


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


More information about the use-livecode mailing list