| View previous topic :: View next topic |
| Author |
Message |
z_one Master

Joined: 14 Jan 2002 Posts: 269 Location: Canada
|
Posted: Wed Dec 12, 2007 7:09 am Post subject: TCL error : Invalid timer ID |
|
|
I got the following procedure that kills a given utimer.
| Code: |
proc killthetimer {
global g_timerz
if {[info exists g_timerz(timer:$l_uhost:$l_chan)]} {
putlog "timer ID: $g_timerz(timer:$l_uhost:$l_chan)"
killutimer $g_timerz(timer:$l_uhost:$l_chan)
putlog "killed the timer"
}
} |
When I run it I get the output timer ID: timer13424 then immediately after it I get TCL error: Invalid timer ID.
What's going on ? How can it not kill the utimer if its ID was correctly found ? |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
|
| Back to top |
|
 |
z_one Master

Joined: 14 Jan 2002 Posts: 269 Location: Canada
|
Posted: Wed Dec 12, 2007 8:03 am Post subject: |
|
|
Yep I read this post.
But I also read in another post: http://forum.egghelp.org/viewtopic.php?p=74519 that you can use the [info exists timer] to directly determine if a timer is already running.
Code by "user".
| Code: | if {[info exists timer]} {
killutimer $timer
unset timer
} |
Besides, Sir_Fz explains how to kill a timer when you know the proc it is linked to.
What if my timer is linked to something else like:
| Code: | | set g_timerz(timer:$l_uhost:$l_chan) [utimer 4 "array unset g_linesperhost *$l_uhost*$l_chan*"] |
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Dec 12, 2007 2:02 pm Post subject: |
|
|
1st: Don't mix timer and utimer..
2nd: "info exists timer" only checks wether the variable named "timer" exists or not. It does no check whatsoever wether the name within "timer" actually points to a valid timer or utimer.
As for the post made by "user", it depends on the proc preceding the example you posted, and expects the globalspace variable "timer" to hold the name of a speciffic timer. It also assumes that the code triggered by the timer will unset that very same variable.
3rd: In order to check wether a (u)timer actually exists, search the list generated by "timers" (or "utimers") for the existance of the actual timer. The link posted by Alchera illustrates how this is done.
4th: When creating a (u)timer, do it something like this:
| Code: | | utimer 4 [list array unset g_linesperhost *$l_uhost*$l_chan*] |
This way you don't have to worry about "special" characters and such. In case you wish to keep track of the timer-id, do something like this:
| Code: | | set myvar [utimer 4 [list array unset g_linesperhost *$l_uhost*$l_chan*]] |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|