Faster way to get tabStops?

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Feb 18 19:40:39 EST 2015


Hi Dan,

Don't use repeat loops. Just sort the lines by the number of chars of 
item x and get the lineoffset for that line. When you know the line 
number, you can get the formattedWidth of the longest item in that line 
and base the tabstops on that.

If you use a clever function, you should also be able to sort lines 
directly by the formattedWidth of their respective items, but that might 
be a little slow again.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 2/19/2015 00:50, Dan Friedman 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 lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>




More information about the use-livecode mailing list