There're several ways to do so, for example suppose we have a timer that should execute the proc check:voices.
Code: Select all
timerexists check:voices
Code: Select all
if {[set thetimer [timerexists check:voices]]!=""} {
# if it's == "" then it doesn't exist, otherwise it returns the timerID
killtimer $thetimer
# timer is killed
}
Code: Select all
if {[set timerindex [lsearch -glob [timers] *check:voices*]] != -1} {
# if it's == -1 then it doesn't exist, otherwise it returns the index of this timer.
killtimer [lindex [lindex [timers] $timerindex] 2]
# the 3rd element of this list is the timerID which is now killed.
}
So this way will match whatever case is used.
Code: Select all
foreach thetimer [timers] {
if {[string equal -nocase check:voices [lindex $thetimer 1]]} {
# got a match
killtimer [lindex $thetimer 2]
# killed the timerID which is the 3rd element of $thetimer.
break
# stopped since no need for further checks.
}
}