Repeat loop index
Jan Schenkel
janschenkel at yahoo.com
Mon Jul 14 10:22:00 EDT 2003
--- Jim Lyons <jimlyons at earthlink.net> wrote:
> It was pointed out recently that it is much faster,
> especially for
> increasingly large amounts of text, to "repeat for
> each line of theText"
> than "repeat with i=1 to the number of lines of
> theText". But what if
> you need to know what line you're on in the loop? Do
> you have to use the
> slower form?
>
> TIA,
> Jim Lyons
>
Hi Jim,
The easiest way to do that without sacrificing the
speed advantage of repeat for each is to track the
index by means of a counter ; for example :
put 0 into i
repeat for each line tLine in tVariable
add 1 to i
-- do funny stuff, and use the index in i
-- ...
end repeat
-- the other advantage is that i contains the number
of lines after the repeat
Hope this helped,
Jan Schenkel.
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
More information about the use-livecode
mailing list