Forum OpenACS Q&A: Response to Support for multibyte: .tcl ok .adp not

Collapse
Posted by Kenny Chiang on
Henry, I appled ad-style.tcl patch and pointed my url to /ecommerce and came up with the error like:
[02/May/2001:12:09:52][1649.4101][-conn0-] Error: can't read "user_is_logged_on"
: no such variable
can't read "user_is_logged_on": no such variable
    while executing
"if { $user_is_logged_on } {
    set welcome_message "Welcome back $user_name!  If you're not $user_name, click <a href="$register_url">here</a>."
} ..."
    invoked from within chunk: 1 of adp: ns_adp_parse
[02/May/2001:12:09:52][1649.4101][-conn0-] Error: can't read "welcome_message": no such variable
can't read "welcome_message": no such variable
    while executing
"ns_adp_puts -nonewline  $welcome_message "
    invoked from within chunk: 2 of adp: ns_adp_parse
[02/May/2001:12:09:52][1649.4101][-conn0-] Error: can't read "search_widget": no such variable
can't read "search_widget": no such variable
    while executing
"ns_adp_puts -nonewline  $search_widget "
 invoked from within chunk: 3 of adp: ns_adp_parse
[02/May/2001:12:09:52][1649.4101][-conn0-] Error: can't read "recommendations_if_there_are_any": no such variable
Shouldn't the ns_adp_parse be eval in "uplevel 1" ?

I changed the code as follows but had some difficulty to get the quote working. can someone point out what is wrong in the code:

set mimetype [ns_guesstype $fully_qualified_template_filename]
set encoding [ns_encodingfortype $mimetype]

set fd [open $fully_qualified_template_filename r]
fconfigure $fd -encoding $encoding
set template [read $fd]
close $fd

if { $cache_p } {
  # build the http header, with a no cache pragma if cache_p is 0
    set http_header "HTTP/1.0 200 OK
MIME-Version: 1.0
Content-Type: $mimetype
Pragma: No-Cache

"
    eval "uplevel { ns_write "$http_header[ns_adp_parse -string "$template"]" }"
} else {
    eval "uplevel { ns_return 200 $mimetype [ns_adp_parse -string "$template"] }"
}

The error message of above code look like this:

[02/May/2001:13:52:30][1984.8201][-conn4-] Error: extra characters after close-quote
extra characters after close-quote
    while executing
"ns_write "HTTP/1.0 200 OK
MIME-Version: 1.0
Content-Type: text/html; charset=big5
Pragma: No-Cache

[ns_adp_parse -string "Welcome to [ec_s..."
    ("uplevel" body line 1)
    invoked from within
"uplevel { ns_write "HTTP/1.0 200 OK
MIME-Version: 1.0
Content-Type: text/html; charset=big5
Pragma: No-Cache

[ns_adp_parse -string "Welcom..."
    ("eval" body line 1)
    invoked from within
"eval "uplevel { ns_write "$http_header[ns_adp_parse -string "$template"]"
 }""
    (procedure "ad_return_template" line 68)