| View previous topic :: View next topic |
| Author |
Message |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Tue May 26, 2015 5:34 am Post subject: Killtimers timerID... |
|
|
How to find the timerID from these examples?
1)
| Code: | | utimer 120 [list putquick [encoding convertfrom utf-8 "PRIVMSG $chan :This is a quick message converted to UTF-8"]] |
2)
| Code: | | timer 3 [list putmsg $chan "Hello world"] |
_________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue May 26, 2015 9:41 am Post subject: Re: Killtimers timerID... |
|
|
Play with this.
It is not meant for any actual use. It is just meant to illustrate.
| Code: |
# May 26, 2015
# http://forum.egghelp.org/viewtopic.php?p=104159&sid=f40235b3e21a35b95678280c8ef33c3f#104159
### this finds only the first instance
bind pub - "!timers" search_timers
proc search_timers {nick uhost handle chan text} {
putserv "privmsg $chan :timers are: [timers]"
putserv "privmsg $chan :text is: $text"
putserv "privmsg $chan :position in list of timers is: [lsearch -index 1 [timers] "*$text*" ] "
set pos [lsearch -index 1 [timers] "*$text*" ]
putserv "privmsg $chan :selected timer is: [lindex [timers] $pos]"
set selected [lindex [timers] $pos]
putserv "privmsg $chan :timer id is: [lindex $selected 2]"
}
###############
#### this will list all timers that match
bind pub - "!timersagain" find_all_timer_matches
proc find_all_timer_matches {nick uhost handle chan text} {
putserv "privmsg $chan :timers are: [timers]"
putserv "privmsg $chan :text is: $text"
set pos "[lsearch -index 1 -all [timers] "*$text*" ]"
putserv "privmsg $chan :selected timers are in these positions : $pos "
foreach num $pos {
putserv "privmsg $chan :timer is: [lindex [timers] $num]"
}
foreach num $pos {
putserv "privmsg $chan :timerid is: [lindex [timers] $num 2]"
}
}
|
Reference:
http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
and
http://www.tcl.tk/man/tcl8.6/TclCmd/lindex.htm
and
http://www.tcl.tk/man/tcl8.6/TclCmd/lsearch.htm
You may wish to experiment with the -nocase switch.
I hope this helps. _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue May 26, 2015 10:32 am Post subject: |
|
|
Also, if you expect to need the timer id often, store it in a variable when you set the timer... | Code: | | set utimerid [utimer 120 [list putquick [encoding convertfrom utf-8 "PRIVMSG $chan :This is a quick message converted to UTF-8"]]] |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Tue May 26, 2015 4:15 pm Post subject: |
|
|
| SpiKe^^ wrote: | Also, if you expect to need the timer id often, store it in a variable when you set the timer... | Code: | | set utimerid [utimer 120 [list putquick [encoding convertfrom utf-8 "PRIVMSG $chan :This is a quick message converted to UTF-8"]]] |
|
Thanks to the contribution willyw.
I liked the idea of SpiKe^^ to keep the timerID in a variable, I tried it and it works perfect.
Thank you both.  _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
|