On 5/26/05, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote:
> Stephen,
>
> Can you please give us some examples how to use the
> ns_parseargs call? I would like to integrate this
> in our code now and would need to instruct all my
> collegues how to use it.
>
> Just a couple of examples would be sufficient.
>
> Thanks
> Zoran
proc ex1 {args} {
ns_parseargs {-a {-b ""} -- x {y Y} args} $args
if {[info exists a]} {
return [list $a $b $x $y $args]
}
return [list $b $x $y $args]
}
There's some use of ns_parseargs in the nstest_http proc of the test
harness, and of course in ns_parseargs.test.
We should probably define ns_proc to allow a more natural usage. I
didn't do that at first as we were discussing extra features such as
type checking. Do you think we can make that backwards compatible?
proc ns_proc {name spec body} {
proc $name {args} "
ns_parseargs $spec \$args
$body
"
}
ns_proc ex2 {-a {-b ""} -- x {y Y} args} {
if {[info exists a]} {
return [list $a $b $x $y $args]
}
return [list $b $x $y $args]
}