Posted to tcl by aspect at Fri Sep 19 05:18:57 GMT 2014view pretty

namespace eval macros {
    variable time
    proc tick {} {
        variable time
        incr time
        after 1000 ::macros::tick
    }
    proc schedule {} {
        after 1000 ::macros::tick
        foreach {interval message} {2000 run1 5000 run2} {
            after $interval [list ::macros::run $message]
        }
    }
    proc run {what} {
        variable time
        puts "Running $what at time $time"
    }
}