From: jemptymethod on 23 Jul 2010 06:55 Somebody suggested the following code to me for debugging an http request: package require http set tok [http::geturl http://localhost:1565/pgn4desk.htm] upvar $tok token set token(body) "" parray token However it results in the following error. I still haven't wrapped my head around upvar :( Hopefully in the near future as I use Tcl more and more. Thanks in advance for any guidance: $ ./tclkit-cli pgn4desk.vfs/debug.tcl bad level "::http::1" while executing "upvar $tok token" (file "pgn4desk.vfs/debug.tcl" line 3)
From: Uwe Klein on 23 Jul 2010 07:09 jemptymethod wrote: > Somebody suggested the following code to me for debugging an http > request: > > package require http > set tok [http::geturl http://localhost:1565/pgn4desk.htm] > upvar $tok token > set token(body) "" > parray token > > However it results in the following error. I still haven't wrapped my > head around upvar :( Hopefully in the near future as I use Tcl more > and more. Thanks in advance for any guidance: > > $ ./tclkit-cli pgn4desk.vfs/debug.tcl > bad level "::http::1" > while executing > "upvar $tok token" > (file "pgn4desk.vfs/debug.tcl" line 3) package require http set tok [http::geturl http://localhost:1565/pgn4desk.htm] # there is no level further up than (the current) toplevel scope thus # upvar wants that optional level argument: upvar #0 $tok token set token(body) "" parray token #or package require http set tok [http::geturl http://localhost:1565/pgn4desk.htm] set ${tok}(body) "" parray $tok uwe
From: Alexandre Ferrieux on 23 Jul 2010 08:11 On Jul 23, 1:09 pm, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote: > jemptymethod wrote: > > Somebody suggested the following code to me for debugging an http > > request: > > > package require http > > set tok [http::geturlhttp://localhost:1565/pgn4desk.htm] > > upvar $tok token > > set token(body) "" > > parray token > > > However it results in the following error. I still haven't wrapped my > > head around upvar :( Hopefully in the near future as I use Tcl more > > and more. Thanks in advance for any guidance: > > > $ ./tclkit-cli pgn4desk.vfs/debug.tcl > > bad level "::http::1" > > while executing > > "upvar $tok token" > > (file "pgn4desk.vfs/debug.tcl" line 3) > > package require http > set tok [http::geturlhttp://localhost:1565/pgn4desk.htm] > # there is no level further up than (the current) toplevel scope thus > # upvar wants that optional level argument: > upvar #0 $tok token > > set token(body) "" > parray token > > #or > package require http > set tok [http::geturlhttp://localhost:1565/pgn4desk.htm] > set ${tok}(body) "" > parray $tok > > uwe Note that the confusing error message bad level "::http::1" is now (8.6) replaced by the accurate bad level "1" since the root cause of the problem is the fact that, without an explicit level, upvar assumes [upvar 1] (meaning one up), which here is invalid as you said, since we're already at toplevel. This message improvement was part of the fix for bug 2673163: https://sourceforge.net/tracker/index.php?func=detail&aid=2673163&group_id=10894&atid=110894 -Alex
|
Pages: 1 Prev: TkX Next: How to split a list when calling a proc with variable arguments |