I\'m having some issues with Tcl. I have a variable that has a string in it. Butt now I want this string to be the name of a next variable.
I have found some similar que
The correct solution is to use $name
as first parameter to set
set name "foo"
set $name "bar"
puts $foo ;# -> bar
But if you try to use $name
it will yield foo
, not bar
(Which is what you do in your code according to the comments. I don't know why you need a variable whose name you don't know, but anyway:
puts [set $name] ;# -> bar
will give you the correct thing. The same works with objects:
set topcell [[set $name] topcell]
So I have to ask you: what do you want to do with the dynamic named variable then?