Gack - I can't see how the counter(total) would be {} and not 0.
Also, 3.2 does CGI for me just peachy. I'm not saying there isn't
a bug (Petrus also reported problems), just that I'm not enlightened
on this one yet.
proc counter::init {tag args} {
upvar #0 counter::T-$tag counter
if {[info exists counter]} {
unset counter
}
set counter(N) 0 ;# Number of samples
set counter(total) 0
set counter(type) {}
# Much counter-type-specific code deleted
}
proc Count {what {delta 1}} {
if {![counter::exists $what]} {
counter::init $what
}
counter::count $what $delta
}
[EMAIL PROTECTED] said:
> the counter::exists cgihits returned 1 since the array already
> existed from somewhere else.
So, I'd like to know where that "somewhere else" is!
>>>"Derek McEachern" said:
>
> Has anyone else found this problem yet.
>
> I'm running tclhttpd3.2 on windows NT. tcl cgi scripts that worked
> fine under tclhttp3.0.3 no longer work because of what appears to be
> a problem in the tclllib0.7 counter library.
>
> Here's the error:
>
> can't use empty string as operand of "+"
> while executing
> "expr {$counter(total) + $delta}"
> (procedure "counter::count" line 3)
> invoked from within
> "counter::count $what $delta"
> (procedure "Count" line 5)
> invoked from within
> "Count cgihits"
> (procedure "CgiSpawn" line 26)
> invoked from within
> "CgiSpawn $sock $path"
> (procedure "CgiHandle" line 4)
> invoked from within
> "CgiHandle /dm6/index.cgi {} C:/dmc/tcl/tclhttpd3.2/bin/../htdocs/dm6/index.
cgi sock184"
>
>
> This is what I was able to come up with. When tclhttpd3.2 is started the
> array counter::T-cgihits(total) is set to {}. When the "Count cgihits" proc
> which calls tclhttpd3.2/lib/counter.tcl--Count proc, the counter::exists cgi
hits
> returned 1 since the array already existed from somewhere else. This then c
aused
> the counter:counter proc in the tcllib to produce the above error.
>
> I modified the counter::exists proc in the counter.tcl standard lib to:
>
> proc counter::exists {tag} {
> upvar #0 counter::T-$tag counter
> if {![info exists counter] ||
> ($counter(total) < 0) } {
> return 0
> } else {
> return 1
> }
> }
>
>
> This seems to have fixed things for me though I'm not sure if this
> is the optimal solution.
>
> Suggestions..
>
> Derek
>
> Derek McEachern
> Texas Instruments
> Systems Development DMOS4
> Phone: 972-995-2813
> Pager: 888-799-6407
> Email: [EMAIL PROTECTED]
>
-- Brent Welch <[EMAIL PROTECTED]>
http://www.ajubasolutions.com
Scriptics changes to Ajuba Solutions
scriptics.com => ajubasolutions.com