properties vs local variable

Mark Schonewille m.schonewille at economy-x-talk.com
Mon Mar 10 16:00:35 EDT 2014


Hi Terry,

Since the arrays don't add any efficiency in this case (as expected), 
perhaps it is a good idea to use a different approach. I understand that 
even fields should always have backColor 62,117,215 and white as the 
foreColor, unless line tLineNum of tSelectedData is not true. If line 
tLineNum of tSelectedData is not true, then you want even end odd fields 
to have different colours. There are a few ways to increase speed here.

First of all, you can make a group with colorized fields. Depending on 
how often line tLineNum of tSelectedData is true or false, you can give 
fields the required colours and only set the foreColor and backColor of 
a field if it has to change. This could increase speed by almost 50%, 
again depending on the values of line tLineNum of tSelectedData.

You can also change the repeat loop, using constants instead of 
variables. If I'm not mistaken, your repeat loop should now look like this:

    repeat for each line tRecData in tData
       put item 1 to tCols of tRecData into tFldData
       put 1 into tFldNum
       if line tLineNum of tSelectedData = true then
          // commenting out the following lines,
          // assuming fields have these colours by default
          // put "62,117,215"  into tBackColor
          // put "255,255,255"  into tForeColor
          repeat for each item tCellData in tFldData
             put tCellData into fld tFldNum of me
             // the next two lines should no longer be necessary
             // set the backgroundColor of fld tFldNum of me to
             // tBackColor
             // set the foregroundColor of fld tFldNum of me to
             // tForeColor
             add 1 to tFldNum
          end repeat
       else
          if tLineNum mod 2 = 0 then
             repeat for each item tCellData in tFldData
                put tCellData into fld tFldNum of me
                set the backgroundColor of fld tFldNum of me to \
                   "244,246,250"
                set the foregroundColor of fld tFldNum of me to black
                add 1 to tFldNum
             end repeat
          else
             repeat for each item tCellData in tFldData
                put tCellData into fld tFldNum of me
                set the backgroundColor of fld tFldNum of me to white
                set the foregroundColor of fld tFldNum of me to black
                add 1 to tFldNum
             end repeat
          end if
       end if
       add 1 to tLineNum
    end repeat

This could be a little faster.

--
Best regards,

Mark Schonewille

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

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

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

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

On 3/10/2014 16:30, Terence Heaford wrote:
> Mark,
>
> Set thText is just a setProp routine in the group to receive the return/tab delimited data.
>
> thText then sets a custom property of the group plus the scrollbar settings depending on the number of lines in the data
>
> displayData is the only routine that places data into the fields.
>
>
> All the best
>
> Terry
>





More information about the use-livecode mailing list