JUAN COLON <[EMAIL PROTECTED]> wrote:
> how do you loop a list? say when the list reaches the last number.
Hi Juan,
You could create a simple Parent Script:
-- Parent Script "Loop List" --
property myList
property myCounter
on setList(me, aList)
myList = aList
myCounter = 0
end setList
on getNextListItem(me)
-- Use the mod function to reset to (0 + 1) when we reach the end of
-- the list
myCounter = (myCounter mod myList.count()) + 1
return myList[myCounter]
end getNextListItem
-- In the Message Window:
x = script("Loop List")
x.setList([1, 2, 3])
put x.getNextListItem()
-- 1
put x.getNextListItem()
-- 2
put x.getNextListItem()
-- 3
put x.getNextListItem()
-- 1
Note that I have included no error checking in the setList() handler.
You should really check if <aList> is a list, and that it has at least
one entry.
Cheers,
James
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/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!]