Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设filevalue_$thefile 是一个包含列表的数组
foreach element [array names thefilevalue_$thefile] { puts "[lindex $thefilevalue_[subst $thefile]($element) 0]" }
但它返回:
can't read "thefilevalue_": no such variable
我在 tcl 8.4 中,我不会升级它。
我该如何解决?
谢谢
使用set和转义括号,例如
set
array set thefilevalue_test {reds {orange red purple} blues {green blue purple}} set thefile test foreach element [array names thefilevalue_$thefile] { puts [lindex [set thefilevalue_$thefile\($element\)] 0] }
这为我输出(Tcl 8.0.5,我也无法升级):
orange green