Object.KillTimer Event Not Working

Wednesday, August 6, 2003 by deleted | Discussion: 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!!
pjpowell
Reply #1 Friday, August 8, 2003 5:19 AM
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.
deleted
Reply #2 Saturday, August 9, 2003 1:08 PM
Thanks, PJ, just tried it, but unfotunatley it doesn't work. Is anyone else having this problem?
deleted
Reply #3 Sunday, August 10, 2003 6:20 PM
Same problem in the newest version of DX. Could someone else please test the above posted code? It would be very much appreciated. Thanks!
pjpowell
Reply #4 Monday, August 11, 2003 6:50 AM
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.
pjpowell
Reply #5 Monday, August 11, 2003 6:57 AM
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

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01