Forum OpenACS Q&A: Response to Tcl question

Collapse
3: Response to Tcl question (response to 1)
Posted by Michael A. Cleverly on
You want to do this:
set test1 25
set number 1
set test test$number
set t [set $test]
Now t will have the value of 25. It's easy to see what Tcl is doing if you drop to a shell and fire up tclsh:
% set test1 25
25
% set number 1
1
% set test test$number
test1
% set t [set $test]
25
[set] when it receives only one argument treats that argument as the name of a variable and returns the value of the variable (if it exists--or throws an error if it doesn't exist). See http://aolserver.com/docs/tcl/tcl8.3/TclCmd/set.htm.