Very humbly, I think that there is a design flaw in the event plugin.
An issue may arise when script A creates an event, saves its
handle, then this same event self-destroys but script A keeps the
handle in store. When script B creates another event the handle is
reused, so script A may think that its event still exists while it
doesn't. In pseudo-code (.at. stands for the at sign):
.at.A
Ae = event.create(Ax,Ay,"event.destroythis")
...
if (event.exists(Ae)) do
; something
endif
quit
.at.B
Be = event.create(Bx,By,Bz)
...
quit
Suppose that the above commands are executed in the following
sequence--and this may indeed happen because unpredictable timers
are involved with events:
Ae = event.create(Ax,Ay,"event.destroythis")
=> sets Ae = 1
Ae."event.destrothis"
=> destroys event Ae, but variable Ae still holds the value 1
Be = event.create(Bx,By,Bz)
=> sets Be to 1 because the event handle is reused
if (event.exists(Ae)) do
=> since Ae == 1 and Be == 1 and event.exists(1) == true, the if branch
==> is executed. Obviously this is in error, because handle 1 points to
B's event, not to A's which self-destroyed.
This problem is hard to reproduce but can happen. In fact, it happens
fairly often on my system, since many of my scripts use events.
Maybe seasoned PP scripters may show me a way to use event that don't
fail in this way, but I don't think that there is such a way, because in
the above example scripts A and B are totally independent and they don't
know each other.
One solution to the above problem is to add two services
event.setname--to set the name of an event to an arbitrary string--and
its companion event.getname--to retrieve the name. The following
pseudocode would solve the issue:
E = event.create(x,y,z)
event.setname(E)="MyName"
...
if(event.exists(E) && event.getname(E) == "MyName")do
; this *IS* my event
endif
Bruce, would you add this to the event plugin? Thanks.
--sgp
**** EDIT YOUR POSTINGS !!!! ****
Please remove as much as possible from original messages before replying to them.
________________________________________________
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/