In need of speed; Array errors

Dave Cragg dcragg at lacscentre.co.uk
Fri May 17 10:09:00 EDT 2002


At 4:17 pm +0200 17/5/02, Terry Vogelaar wrote:
>I need to do calculations with sets of 3 cards in a stack. It seems wise to
>me to copy the data into an array first and then repeat through the array
>instead of through the stack. But it still is a terribly slow script. Are
>there any suggestions to help me make this work faster? The slow but
>correctly working version is this:
>
>on mouseup
>   repeat with e = 1 to the number of cds
>     put the short id of cd e into ky
>     put fld "data" of cd e into advs[ky]
>   end repeat
>   put the keys of advs into vKeys
>   repeat with e = 1 to the number of lines of vKeys -2
>     put advs[line e of vKeys] into eVar
>     repeat with f = e+1 to the number of lines of vKeys -1
>       put advs[line f of vKeys] into fVar
>       repeat with g = f+1 to the number of lines of vKeys
>         put advs[line g of vKeys] into gVar
>         -- some more lines of script, unimportant for this post
>       end repeat
>     end repeat
>   end repeat
>end mouseup
>

This is not tested. But I think you're doing a lot of unnecessarry 
line references into the keys of the array. Why not just use the card 
numbers as the keys?

on mouseup
   repeat with e = 1 to the number of cds
     put fld "data" of cd e into advs[e]
   end repeat
   put the keys of advs into vKeys
   put the number of lines of vKeys into vNumKeys
   repeat with e = 1 to vNumKeys -2
     put advs[e] into eVar
     repeat with f = e+1 to vNumKeys -1
       put advs[f] into fVar
       repeat with g = f+1 to vNumKeys
         put advs[g] into gVar
         -- some more lines of script, unimportant for this post
       end repeat
     end repeat
   end repeat
end mouseup


Cheers
Dave Cragg



More information about the use-livecode mailing list