Forum OpenACS Development: Re: Problems with ns_schedule_daily

Collapse
Posted by Don Baccus on
You're being caught by not properly understanding Tcl semantics.

Note the difference between your example and the Tcl manual example here:

set id [ns_schedule_daily -once 5 35 { ns_log notice "It is now 5:35 AM." }]
Commands enclosed in square brackets are executed immediately by the Tcl interpreter. So the "ns_log" command is actually executed BEFORE the call to ns_schedule_daily call. It appears to "not run the second day" because it's already been executed - the RESULT of "ns_log" (which is the empty string) is being executed every day which of course doesn't cause anything to show up in your output log.

In contrast, the example in the Tcl API document surrounds the ns_log in CURLY not SQUARE braces. This simply passes the list, unevaled, to ns_schedule_daily. So that list (ns_log Notice "scheduling a script"), rather than the result from EVALing it is then stored by ns_schedule and you get the results you expect.

Hope this helps you ... the semantics of quoting, square-bracketing, and curly-bracketing in the Tcl interpreter is crucial to understanding how things work. It's simple once you understand the rules, though.