Published on August 6, 2003 By deleted In Skinning
I am using DesktopX 1.99c[b] and I don't believe that the Object.KillTimer event works in VBScript. I have created a test program. In the program, if the coding works as I think it does, when you click on the object,the timer is set, a message box should pop up when the timer goes off, and then the timer should be killed. Instead I am finding that th emessage boxes keep appearing and appearing until you disable the script on the object. Here is the code I am using to test it:

----------------

'Called when the script is executed
Sub Object_OnScriptEnter
TimerExecuted=0
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

'Called when the object state is changed
Sub Object_OnStateChange(State)
If Object.State = "Command executed" Then
Object.SetTimer 1, 5.6
End If
End Sub

Sub Object_OnTimer1
Script.MsgBox "This should only display once if Timer 1 is being killed."
Object.KillTimer1
End Sub

----------------

Unless my coding is flawed (which is very possible) it appears that the KillTimer even is not working. Why is it not working? Thanks!!
Comments
on Aug 08, 2003
Try setting your timer to greater than 5 milliseconds. It's probably queueing events. Set to 500 or even 1000 to make sure the killtimer really isn't firing.
on Aug 09, 2003
Thanks, PJ, just tried it, but unfotunatley it doesn't work. Is anyone else having this problem?
on Aug 10, 2003
Same problem in the newest version of DX. Could someone else please test the above posted code? It would be very much appreciated. Thanks!
on Aug 11, 2003
Oops. Just noticed something I missed first time round.

You need:

Object.KillTimer 1

not

Object.KillTimer1

Of course you may have that and just mistyped into the messageboard.
on Aug 11, 2003
Not sure why I didn't spot this immediately.

The problem is that you are showing a msgbox before killing the timer. This basically halts that part of the script until it is responded to. In the meantime there is the potential for another ontimer event to be fired and get to the same point no matter what interval you use.

You just need to move the msgbox bit after the killtimer line so that it kills the timer and then shows the message.

Sub Object_OnTimer1
Object.KillTimer 1
Script.MsgBox "This should only display once if Timer 1 is being killed."
End Sub