Most Effecient way to repeat a handler/function - Found word(s) list error in the Text body

Peter M. Brigham pmbrig at gmail.com
Mon Feb 17 15:39:02 EST 2014


On Feb 16, 2014, at 10:23 PM, Geoff Canyon wrote:

> On Sun, Feb 16, 2014 at 2:52 PM, Bob Sneidar <bobsneidar at iotecdigital.com>wrote:
> 
>> Funny, just before I read your post I was thinking, "I wonder if this
>> scales linearly or logarithmically?" GET OUT OF MY HEAD!!! ;-)
> 
> It's pretty much my personal quest to convince everyone never to use repeat
> with i = 1 to the number of anything.

Well, I still do it for i < 1000 or so, and the speed hit is perfectly acceptable for that. The advantage for me is when I must use the number of the iteration I'm in to do something. Sure I could do:

put 0 into tCounter
repeat for each line LL in tList
add 1 to tCounter
…< do things using tCounter here>…
end repeat

but why bother for smaller sets of data?

While we're dreaming of syntax extensions, how about this:

repeat for each line LL in tList with counter = "tCounter"
-- the variable tCounter would automatically be initialized then incremented with each iteration
...< do things using tCounter here>…
end repeat

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig





More information about the use-livecode mailing list