On Thu, 04 Oct 2007 13:02:45 +0200
Massimo Manghi <[EMAIL PROTECTED]> wrote:

> Cristian wrote:
> >
> > So if I understand it correctly,
> > wouldn't the following solve the problem?
> >
> i suspect the answer depends on what you expect from
> load_response. 
> 
> 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

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?

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.

Also to note is that when a var had no value, response(var) was an empty 
string, not an empty list.

The following code within load_response would achieve this:

foreach {var elem} [var all] {
        if {[info exists response(__$var)]} {
                # we have seen var multiple times already, add to the list
                lappend response($var) $elem
        } elseif {[info exists response($var)]} {
                # second occurence of var,  convert response(var) list:
                set response($var) [list $response($var) $elem]
                set response(__$var) ""
        } else {
                # first time seeing this var
                set response($var) $elem
        }
}

So for:
> > http://localhost:8081/load_response_test.rvt?foo=bar+baz&fee=bat&foo=bak 

We get:

response(fee) = bat
response(foo) = {bar baz} bak
response(__foo) = 

And for 
load_response_test.rvt?foo=bar+baz&fee=bat&foo=bak&faa=&fii=bar+baz&foo=bee+bii

response(fii) = bar baz
response(faa) = 
response(fee) = bat
response(foo) = {bar baz} bak {bee bii}
response(__foo) = 

Thoughts?

-fr.

-- 
Feargal Reilly, Chief Techie, FBI.
PGP Key: 0xBD252C01 (expires: 2006-11-30)
Web: http://www.fbi.ie/ | Tel: +353.14988588 | Fax: +353.14988489
Communications House, 11 Sallymount Avenue, Ranelagh, Dublin 6.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to