I have a variable set in my tcl code. e.g: set uname "myuname"
how do I use this in my adp page?. e.g: Your username is: <%puts $uname%>
It does not seem to work, everytime i get a tcl error saying that
uname does not exists. I tried to make uname global, to no avail.
Thank you
--
Xavier Bourguignon
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.
<%= $variable %>
No need for "puts". This works also:
<%= [clock seconds] %>
Which puts the output of that command in the HTML.
But it sounds like you have a scope problem. Any way you can post your
actual code?
If you set the variable inside a procedure, you could use "upvar" to
make it available in the scope where you want to display it. If you
put a variable in the global scope, you can access it like so:
<%= $::variable %>
Bas.
I have done this now: set ::variablename value
in adp: if {$::variablename} {
blah
}
so it works now, but I have no idea as to why I should explicitly add
the :: for this to work. The tcl code runs in a function which has
been registered like this: ns_register_filter postauth.
Thank you
proc ::gs_admin::req_init {conn arg why} {
variable INIT
global REQ
catch {unset REQ}
if {!$INIT} {
ns_log Waning "==>::gs_admin::req_init - gs_admin must be
initialised before use..."
return
}
ns_log Notice "==>Starting request"
# check the user is logged in
set logged_in [::gs_login::logged_in $conn]
if {[lindex $logged_in 0]} {
set REQ(LOGIN_OK) 1
} else {
set REQ(LOGIN_OK) 0
set REQ(LOGIN_REASON) [lindex $logged_in 1]
}
# everything is fine, lets carry on
return "filter_ok"
}
what happend now is that in my adp file I call: <% if {$REQ(LOGIN_OK)} { %>
and I get this error:
can't read "REQ(LOGIN_OK)": no such variable
while executing
"if {$REQ(LOGIN_OK)} {
Very weird indeed.
Is there a way to find out which scope the code is in at any one point
in the execution?
Thank you
I noticed you are using the new parser that allows you to do "... { %>
some html <% } ...", something I have never done. Could it be this
works differently and every block is executed in a different scope?
(i.e.: parsed into a proc and then executed)
Bas.