On 10/4/07, Feargal Reilly <[EMAIL PROTECTED]> wrote:
>
> On Thu, 04 Oct 2007 13:02:45 +0200
> Massimo Manghi <[EMAIL PROTECTED]> wrote:
>
> > A strong point was that load_response is taken from
> > NeoWebScript, a Tcl based web development tool which could be
> > already familiar to the a new Rivet user and it wouldn't make
> > sense to confuse him/her.
>
> If the point of having load_response is to do the same job that
> load_response in nws did, then it should behave as load_response
> did.
>
> The questions then become:
> a) how did load_response deal with multiple submissions of the
> same cgi var, and
Thats history... I can not answer that, but I would like to know too.
b) how, when examing the response array, can you identify
> between response(var) representing a verbatim value, or if it
> represents a var which was submitted multiple times?
with my proposed changes it would be as easy as (untested code)
foreach var [array names response] {
set rlen [llength $response($var)]
if {[$rlen==0} {
# empty value
} elseif {$rlen==1} {
# single value
} else {
# multiple value
}
}
Or use switch...
In any case the programmer should know when to expect a multivalued var or
not.
The answers are that in nws, what load_response did was create
> response(__var) when it encountered more than one value for var,
> and ensured sure that resposne(var) was a list, with each
> element represented one of the submitted cgi values.
__var isn't really necessary as you can check the number of elements in your
response(var) list. One statement to check if multivalued in both cases. One
less var to take care of when using llength.
Also to note is that when a var had no value, response(var) was
> an empty string, not an empty list.
It should be an empty list if only to be consistent with "response(var) is a
list". But fortunately in Tcl that does not matter much as both can be
converted back and forth, where [llength ""] and [llength [list]] give the
same result... the cost? a bit of shimmering ;-)
In any case [var all] returns an empty string when var has no value so the
var with the empty string will be present in the array.
<snip code and examples>
Anyways, those were my 2 cents... hope to see more cents coming in.
Cheers,
Cristian.