Version 0 of clock quirk

Updated 2009-01-01 23:40:38 by pa_mcclamrock

D. McC 2009/01/01: Something strange just happened when I was running supposedly simple "clock" commands from a procedure (using Tcl 8.5.5 on Puppy Linux 4.1.1). The commands, individually, work right:

 % set startdate 2009/01/14
 2009/01/14

 % set scanno [clock scan $startdate -format "%Y/%m/%d"]
 1231862400

 % set quant 1
 1

 % set unit year
 year

 % set addo [clock add $scanno $quant $unit]
 1263398400

 % set formato [clock format $addo -format "%Y/%m/%d"]
 2010/01/14

But then I put the same commands into a proc, and I got an error message:

 % proc recur {startdate unit quant} {
        set scanno [clock scan $startdate -format "%Y/%m/%d"]
        set addo [clock add $scanno $quant $unit]
        set recurdate [clock format $addo -format "%Y/%m/%d"]
         return $recurdate
 }
 % recur 2009/01/14 1 year
 can't read "flag": no such variable

Running the proc from within a GUI in an app I'm trying to develop, I get these details in the error dialog:

 can't read "flag": no such variable
 can't read "flag": no such variable
    while executing
 "list CLOCK badSwitch $flag"
    (procedure "::tcl::clock::add" line 37)
    invoked from within
 "clock add $scanno $quant $unit"
    (procedure "recur" line 55)
    invoked from within
 "recur $startdate $unit $quant"
    (procedure "markok" line 10)
    invoked from within
 "markok .li(1)"
    invoked from within
 ".li(1).ok invoke"
    ("uplevel" body line 1)
    invoked from within
 "uplevel #0 [list $w invoke]"
    (procedure "tk::ButtonUp" line 22)
    invoked from within
 "tk::ButtonUp .li(1).ok"
    (command bound to event)

Can anybody tell me what's going on here and how to fix it? If so, thanks in advance!


enter categories here