Phil White wrote:
>Franco:
>
>Your mode = 1 code is deleting from the list, so when your halfway
>through there are only 50 items in the list. Index of 51 gives error.
>To see it in action , try this:
>
> repeat with i = 1 to cnt
> put i
> (the timeoutList[i]).forget()
> put the timeoutList.count()-- Decrements to 50 then, ERROR
> end repeat
You are absolutely right! I omitted to remember that when an item
is deleted from a list the remaining ones shift up by one position.
Moreover the timeoutList's case appear be the same as with linear
lists:
linearList.deleteAt(itemNumber)
So, thank for your fix.
To recap about deleting a list of timeout objects:
- I encountered that problem because I wanted to be sure that
the timeoutList was emptied on the movie stop. But in the Help
it is clearly said that when timeoutObject.persistent has not
been explicitly set to TRUE for a given timeout object, this is
removed from the timeoutList when the current movie stops playing.
So there's no need to write code for this purpose in the case
any of the objects in the list has been explicitly defined as
persistent.
- If the above is not the case, it seems that 'the timeoutList = []'
works fine, as well as 'the actorList = []' works for the actorList.
I could not notice any side-effect.
- But whether you want to empty the timeoutList using the canonical
.forget() method, here are two working handlers derived from the
one in my previuos posting:
--(A) Empty the list by deleting the first current item
repeat while the timeoutList.count()
(the timeoutList[1]).forget()
end repeat
--(B) Empty the list by deleting the last current item
repeat while the timeoutList.count()
(the timeoutList[the timeoutList.count()]).forget()
end repeat
They should work also with linear lists, provided that the line
of code accomplishing the deletion is replaced by something like:
linearList.deleteAt(1) -- (A1)
linearList.deleteAt(linearList.count()) -- (B1)
I'd expect that (B1) is faster than (A1), since items don't shift
up one position with (B1). But I could be wrong because, in both
the cases, the list appears need some rebuild by the underlaying
code.
Of course it'd make no sense deleting a linear List by (A1) or (B1)
since we are allowed to set linearList = [].
But it could have whether we need to delete a number of items greater
than the half of the items in the list.
E.g. if we want to delete the first 70 items in a 100 items list,
we could use the handler (A) modified according to (A1).
This should prevent the halfway "Index out of range" error.
Kind regards,
Franco
IFC Programming Consultant
http://www.chnexus.com/main.htm
Private mailto:[EMAIL PROTECTED]
[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!]