Forum OpenACS Q&A: Re: How to upvar an array in a recursive procedure

Collapse
Posted by Brad Duell on
Not sure if this helps, but here's what I used to export url vars with array values in our old ACS implementation...

proc_doc nca_export_url_vars {
    {args ""}
} {
} {
    set params {}
    foreach var $args {
    upvar 1 $var value
    if { [array exists value] } {
        # Array
        foreach {index array_value} [array get value] {
        if { [info exists array_value] && ![empty_string_p $array_value] } {
            lappend params "$var\($index\)=[ns_urlencode $array_value]"
        }
        }
    } else {
        # Normal Variable
        if { [info exists value] } {
        lappend params "$var=[ns_urlencode $value]"
        }
    }
    }
    return [join $params "&"]
}