simple tcl question: how to substitute variable into another variable name?
在編寫tcl程序時候,可能會遇到如下問題:
set a 10
set b$a 20
當需要輸出是,
puts $b10 ==> 20
puts $b$a ==> error "no varibale b"
此時由於tcl在變量替換中,僅執行了一次替換,b與a 分別再一次替換中。
可以使用如下命令實現:
[expr \$b$a]
可以輸出你想要的。