[EMAIL PROTECTED] wrote:
Folks,

I'll likely submit an enhancement request for this. However, SourceForge is down at the moment, so I thought I'd bounce the idea off the mailing list so I didn't forget...

I've seen an awful lot of code that does something along the lines of:

set myVar [ns_adp_argv 1]
if { ![string length $myVar] } {
    set myVar "some default value"
}

I was thinking it might be a good idea to change the ns_adp_argv command to accept a second "default value" argument that gets returned either:
* When there aren't /X/ values supplied with the ns_adp_include, or
* When the value of the [ns_adp_argv /X//]/ would return the empty string.

I prefer the first, as it allows the caller to specifically supply an empty string if that is, indeed, what they want. I'd consider it akin to the database NULL vs. empty string issue.

Rob Seeger

-- AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

I've gone ahead and extended the "ns_adp_argv" command to allow you to pass an additional optional value that will get returned if the args index being requested does not exist. This change should be backwards compatible, and is available on the HEAD, which will eventually be tagged and released.

Examples:

   ns_adp_include foo.inc a "" c

   ns_adp_argv 1 -> a
   ns_adp_argv 2 ->
   ns_adp_argv 5 ->
   ns_adp_argv 5 "default" -> default

Thanks Rob!

- n


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to