ad_export_vars (public, deprecated)
ad_export_vars [ -form ] [ -exclude exclude ] [ -override override ] \
[ include ]Defined in packages/acs-tcl/tcl/deprecated-procs.tcl
Deprecated. Invoking this procedure generates a warning.
Note This proc is deprecated in favor of
export_vars. They're very similar, butexport_varshave a number of advantages:It doesn't have the
- It can sign variables (the
:signflag)- It can export variables as a :multiple.
- It can export arrays with on-the-fly values (not pulled from the environment)
foo(bar)syntax to pull a single value from an array, however, but you can do the same by sayingexport_vars {{foo.bar $foo(bar)}}.Helps export variables from one page to the next, either as URL variables or hidden form variables. It'll reach into arrays and grab either all values or individual values out and export them in a way that will be consistent with the ad_page_contract :array flag.
Example:
will export the variabledoc_body_append [export_vars { msg_id user(email) { order_by date } }]msg_idand the valueuser, and it will export a variable namedorder_bywith the valuedate.The args is a list of variable names that you want exported. You can name
- a scalar variable,
foo,- the name of an array,
bar, in which case all the values in that array will get exported, or- an individual value in an array,
bar(baz)- a list in [array get] format { name value name value ..}. The value will get substituted normally, so you can put a computation in there.
A more involved example:
set my_vars { msg_id user(email) order_by } doc_body_append [export_vars -override { order_by $new_order_by } $my_vars]
- Switches:
- -form (optional, boolean)
- set this parameter if you want the variables exported as hidden form variables, as opposed to URL variables, which is the default.
- -exclude (optional)
- takes a list of names of variables you don't want exported, even though they might be listed in the args. The names take the same form as in the args list.
- -override (optional)
- takes a list of the same format as args, which will get exported no matter what you have excluded.
- Parameters:
- include (optional)
- Author:
- Lars Pind <lars@pinds.com>
- Created:
- 21 July 2000
- See Also:
- Testcases:
- No testcase defined.
Source code: ad_log_deprecated proc ad_export_vars #################### # # Build up an array of values to export # #################### array set export [list] set override_p 0 foreach argument { include override } { foreach arg [set $argument] { if { [llength $arg] == 1 } { if { $override_p || $arg ni $exclude } { upvar $arg var if { [array exists var] } { # export the entire array foreach name [array names var] { if { $override_p || "${arg}($name)" ni $exclude } { set export($arg.$name) $var($name) } } } elseif { [info exists var] } { if { $override_p || $arg ni $exclude } { # if the var is part of an array, we'll translate the () into a dot. set left_paren [string first "(" $arg] if { $left_paren == -1 } { set export($arg) $var } else { # convert the parenthesis into a dot before setting set export([string range $arg 0 $left_paren-1].[string range $arg $left_paren+1 end-1]) $var } } } } } elseif { [llength $arg] %2 == 0 } { foreach { name value } $arg { if { $override_p || $name ni $exclude } { set left_paren [string first "(" $name] if { $left_paren == -1 } { set export($name) [lindex [uplevel list \[subst [list $value]\]] 0] } else { # convert the parenthesis into a dot before setting set export([string range $arg 0 $left_paren-1].[string range $arg $left_paren+1 end-1]) [lindex [uplevel list \[subst [list $value]\]] 0] } } } } else { return -code error "All the exported values must have either one or an even number of elements" } } incr override_p } #################### # # Translate this into the desired output form # #################### if { !$form_p } { set export_list [list] foreach varname [array names export] { lappend export_list "[ns_urlencode $varname]=[ns_urlencode $export($varname)]" } return [join $export_list &] } else { set export_list [list] foreach varname [array names export] { lappend export_list "<input type=\"hidden\" name=\"[ns_quotehtml $varname]\" value=\"[ns_quotehtml $export($varname)]\" >" } return [join $export_list \n] }XQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-tcl/tcl/deprecated-procs.xql