one of the documented procedures in this installation of the ACS
export_url_scope_vars   { args "" }
What it does:
assumes scope is set up in the topmost environment. if scope=group it assumes group_id is set in the topmost environment, if scope=user it assumes that user_id is set in topmost environment and if scope=table it assumes on_which_table and on_what_id are set in topmost environment. this procedure operates in the same manner as export_url_vars except that it automatically figures out and sets appropriate scope variables. (e.g. for scope=group_id, export_url_scope_vars return_url would return the following string scope=group&group_id=23&return_url=23
Defined in: /web/philip/tcl/ad-scope.tcl

Source code:

    if { [empty_string_p $args] } {
	set exported_url_vars ""
    } else {
	set url_vars [eval uplevel {"export_url_vars $args"}]
	if { [empty_string_p $url_vars] } {
	    set exported_url_vars ""
	} else {
	    set exported_url_vars &$url_vars


    if { [uplevel [ad_scope_upvar_level] {string compare $scope public}]==0 } {
	return "scope=public$exported_url_vars"
    if { [uplevel [ad_scope_upvar_level] {string compare $scope group}]==0 } {
	upvar [ad_scope_upvar_level] group_id group_id
	return "scope=group&group_id=$group_id$exported_url_vars"
    if { [uplevel [ad_scope_upvar_level] {string compare $scope user}]==0 } {
	upvar [ad_scope_upvar_level] user_id user_id
	return "scope=user&user_id=$user_id$exported_url_vars"
    if { [uplevel [ad_scope_upvar_level] {string compare $scope table}]==0 } {
	upvar [ad_scope_upvar_level] on_which_table on_which_table
	upvar [ad_scope_upvar_level] on_what_id on_what_id
	return "scope=table&on_which_table=[ns_urlencode $on_which_table]&on_what_id=$on_what_id$exported_url_vars"