Repeat for each loop assistance, please.

Jeanne A. E. DeVoto jeanne at runrev.com
Sun Aug 3 03:01:02 EDT 2003


At 10:32PM -0700 8/2/03, Edwin Gore wrote:
>Scott's method (adding a counter) is absolutely the right way to go. Others
>on the list have benchmarked this, and it's MUCH faster than doing the for x
>= etc. etc. etc. method.

Although it should be pointed out that the speed difference is usually
insignificant if you are doing few enough iterations through the loop. (For
example, if you're processing 100 lines and checking the number of items in
each, even "repeat with x =" takes only a couple of milliseconds. On the
other hand, if you're doing 10000 lines, the speed difference becomes much
more important.)

In the case where the speed difference isn't significant, the "repeat with
x" form is a bit more readable since it makes it more obvious that you're
tracking the line number, and this may be enough reason to use that form.

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - Software at the Speed of Thought
http://www.runrev.com/





More information about the use-livecode mailing list