egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCL error : Invalid timer ID

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
z_one
Master


Joined: 14 Jan 2002
Posts: 269
Location: Canada

PostPosted: Wed Dec 12, 2007 7:09 am    Post subject: TCL error : Invalid timer ID Reply with quote

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
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Dec 12, 2007 7:48 am    Post subject: Reply with quote

A simple Search would have saved a post.

Timers (Searching, killing, using time binds)
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
z_one
Master


Joined: 14 Jan 2002
Posts: 269
Location: Canada

PostPosted: Wed Dec 12, 2007 8:03 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Dec 12, 2007 2:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber