Variable variable name

Philip Greenspun's Homepage : Philip Greenspun's Homepage Discussion Forums : 6916 : One Thread
Notify me of new responses
Is it possible to use a variable whose name depends
on the value of another variable?

for example

i have variable j and variable i_0 ~ i_10
i want to use i_$j

-- Tony Chao, March 5, 2000

Answers

Try the set command. For example, set i "the" ns_write "This is the variable for $i and $the_var: [set "[set i]_var"]"

-- Jesse Koontz, March 6, 2000

That way should work but keep in mind that variables with Tcl may not start with a digit (as far as I know and as I expierienced).

-- Dietmar Krauss, July 10, 2000

How to access this newly set variable of variable name ?

How to echo this or run expr on it?

~ishwar

-- ishwar i, May 26, 2009