Timer TCL
#9
salut,

pour ceux que ça intéresserais voila le utimer de eggdrop recodé entièrement en tcl pur avec after (comprend le killutimer et utimers)
tcl
proc timer {time proc} {
 variable timers
  set timerid [after [expr $time*1000] $proc]
  lappend timers "[expr [unixtime] + $time] $proc $timerid" 
  set after($timerid) [after [expr $time*1000] "[namespace current]::unsettimers {[expr [unixtime] + $time] $proc $timerid}"] 
  return $timerid
}
 
proc unsettimers {id} {
 variable timers
  if {[info exists timers] && $timers!=""} {
    set find [lsearch -exact $timers "$id"]
    if {$find!="-1"} {
      set timers [lreplace $timers $find $find]
    }
  }
}
 
proc timers { } {
 variable timers
  if {[info exists timers] && $timers!=""} {
    foreach u $timers {
      set u [charfilter $u]
      set t [lindex $u 0]
      set t [expr $t - [unixtime]]
      lappend ut "$t {[join [lrange $u 1 [expr [llength $u] - 2]]]} [lindex $u end]"
    }
    return $ut
  }
  return
}
 
proc killtimer {timerid} {
 variable timers
  if {[info exists timers] && $timers!=""} {
    foreach u $timers {
      if {[lindex $u end]==$timerid} {
        unsettimers $u
        catch {after cancel $timerid}
      }
    }
  }
}


C'est en reconnaissant ses erreurs que l'on progresse Wink
Répondre Avertir


Messages dans ce sujet
Timer TCL - par BlackNight - 05/07/2009, 13:29
RE: Timer TCL - par fedora - 05/07/2009, 15:40
RE: Timer TCL - par BlackNight - 05/07/2009, 16:01
RE: Timer TCL - par fedora - 05/07/2009, 16:05
RE: Timer TCL - par Artix - 06/07/2009, 09:46
RE: Timer TCL - par fedora - 06/07/2009, 09:55
RE: Timer TCL - par Artix - 06/07/2009, 19:53
RE: Timer TCL - par fedora - 06/07/2009, 21:04
RE: Timer TCL - par djkenny - 07/07/2009, 02:11
RE: Timer TCL - par djkenny - 07/07/2009, 02:14
RE: Timer TCL - par David - 18/07/2009, 11:17
RE: Timer TCL - par BlackNight - 09/08/2009, 02:36
RE: Timer TCL - par Babytigrou16 - 09/08/2009, 18:13
RE: Timer TCL - par BlackNight - 09/08/2009, 19:48
RE: Timer TCL - par DodY - 13/02/2010, 19:11
RE: Timer TCL - par DodY - 13/02/2010, 19:42

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté