0
让我们假设thefilevalue_ $ thefile是包含列表如何替换数组名称中的变量?
foreach element [array names thefilevalue_$thefile] {
puts "[lindex $thefilevalue_[subst $thefile]($element) 0]"
}
一个数组,但它返回:
can't read "thefilevalue_": no such variable
我在TCL 8.4和我续升级。
我该如何解决它?
感谢
它完美!谢谢 ! – heyhey 2012-08-10 14:28:49
考虑使用'upvar 0 thefilevalue_ $ thefile ary'来给这个数组一个较短的名字。它使代码的其余部分更易于编写(例如,'$ ary($ element)'而不是'set'中的这些体操)。 – 2012-08-10 14:43:36
此外,在这种情况下,你可以做'foreach {元素内容} [数组获取文件值_ $文件] {...} – 2012-08-10 14:44:38