This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Utimer problems

Old posts that have not been replied to for several years.
Locked
b
brentos

Utimer problems

Post by brentos »

I am making a trivia bot and I use utimers to decide when the question goes unansered due to time limit. The only thing is if I use the command to stop the bot it is told to kill all the timer and Display a msg saying that trivia is stoped. The only problem is that the timer still keeps running. I put the stop the msg gets printed but after the time limit comes to an end it continues by calling the proc specified in the timer.
Any ideas anyone
I am new to tcl so i can use the help lol
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You must not be killing the timer right. use killutimer $timerid, where $timerid is the code returned by the utimer command.
b
brentos

Post by brentos »

So are you say that you can just kill the timer by using the variable name that you assigned it to? You have to preform the utimer on the variable to get the ID and then kill it?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

no the utimer command returns a timer id

set timerid [utimer 30 blah]

killutimer $timerid
b
brentos

Post by brentos »

I do kill it like that but it still doesn't work
In one module i put

set timeovertimer [utimer 60 tgover]

and in the kill module i say

killutimer timeovertimer

And it won't work
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It doesn't work like that.

You need to get the general idea of the syntax of Tcl.

The "killtimer" command uses a timerid, not a variable name.

The timerid can however, come from within a variable, thus you use it likke "$timerid".
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

does the code below set AND start the timer, or only set a var?

Code: Select all

set mytimer [utimer $av_seconds [list av:dec $chan]] 

and is this the proper way to kill the above timer?

Code: Select all

if {[info exists mytimer]} { 
  killutimer $mytimer
} 
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Dedan wrote:does the code below set AND start the timer, or only set a var?

Code: Select all

set mytimer [utimer $av_seconds [list av:dec $chan]] 
[snip]
this starts the timer and returns a timer id in the var $mytimer.
Dedan wrote: and is this the proper way to kill the above timer?

Code: Select all

if {[info exists mytimer]} { 
  killutimer $mytimer
} 
if $mytimer is running then this will work, but this will also work even when there is no $mytimer running in [utimers] so this will return an error "invalid timerID"
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

so, how are you checking if that timer is running?
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

foreach utimer [utimers] {
if {[string match $mytimer [lindex $utimer 2]]} {
 killutimer $mytimer
 }
}
this should do it.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

thanks :D
I once was an intelligent young man, now i am old and i can not remember who i was.
Locked