I am trying to do the following:
set myvar_key something
set a myvar
proc test {} {
# I am expecting mylocal_var to be "something", but it errors
set mylocal_var [set ${::a}_key]
}
# The proc is called like this
test
Thanks in advance,
Pedro
>Solution :
You’re almost there, but just missed something. As your code already shows, a is in the global namespace, thus you need ::a.
Same is true for myvar_key, thus you need to do
set myvar_key something
set a myvar
proc test {} {
set mylocal_var [set ::${::a}_key]
puts $mylocal_var
}
test
prints "something"