mset {x y z} $l
will:
set x [lindex $l 0]
set y [lindex $l 1]
set z [lindex $l 2]
ok.. fairly simple, mostly I just need to loop over two lists
and do an uplevel and a set.. but I am having problems with
the uplevel:
uplevel 1 set $var $val
works mostly, except it does a concat and eval on the string first
which does weird things if $val happens to have spaces or braces
or other oddities:
set val "1 2 { 3"
uplevel 1 set x $val
ok.. so how do I avoid this? Is there a quoting function that I can
use to protect $val before passing it to uplevel? Is there another
way to implement this?
I tried using itcl's "scope":
uplevel 1 set $var dummy
set svar [uplevel 1 scope $var]
set $svar $val
this works a little better, but doesnt quite work properly when called
from a method of an object to set one of the method's locals..
so.. someone gimme the magic incantations please?
Tim N.
uplevel 1 set [list $var] [list $value]
.. just in case the variable name also contains oddities. (tested
this with non-matching `"' and `{' in it)
Harald Kirsch
--
---------------------+------------------+--------------------------
Harald Kirsch (@home)| | Now I rebooted.
k...@iitb.fhg.de | | --- Jerry Pournelle, BYTE
gegen Punktfilitis hilft nur `chmod u-w ~'
Or
uplevel 1 [list set $var $value]
as suits your taste.
--
| Don Porter, D.Sc. Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/mcsd/Staff/DPorter/ NIST |
|______________________________________________________________________|
Others have answered your questions about quoting hell, uplevel and so
on. Now about the specific tool, are you aware of the following nifty
idiom:
foreach {x y z} $l break
A DN search (foreach break) should bring back the proper credit
information, along with an explanation if you need one.
-Alex