At 08:08 2002-09-21, Andreas Gaunitz P11 wrote:
>I have often wondered if there's a "hidden counter" somewhere that
>Director uses when counting throough the items using 'repeat with anItem
>in aList'? If so, can I check the value of that counter and use it?
I can't speak for how Director does it, but you can get the count of a
"repeat with i in list" by checking the position of i in the list. Of
course, this will not work for lists with duplicate entries.
on repeatList aList
repeat with i in aList
put aList.getPos(i)
end repeat
end
repeatList(["a",1,"b",99,"a"])
-- 1
-- 2
-- 3
-- 4
-- 1
So, I guess you could just increment your own variable.
on repeatList aList
myCount = 1
repeat with i in aList
-- do something
myCount = myCount + 1
end repeat
end
Which just about brings us back to 'using repeat with i = 1 to aList.count'
If you want to make it slightly more efficient, store the list count in a
variable rather than getting the count on every iteration.
cnt = aList.count
repeat with i = 1 to cnt
--
Mark A. Boyd
Keep-On-Learnin' :)
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]