根据我的输入,我有一个存在或不存在的变量,所以我做了一个if:
if { [info exists $var1] } {
puts "Here we are, Born to be kings, We're the princes of the universe ..."
}
Run Code Online (Sandbox Code Playgroud)
但是当我启动我的脚本时,我收到了错误日志:
can't read "var1": no such variable
while executing
"info exists $var1"
Run Code Online (Sandbox Code Playgroud)
怎么了?
我们假设filevalue_ $ thefile是一个包含列表的数组
foreach element [array names thefilevalue_$thefile] {
puts "[lindex $thefilevalue_[subst $thefile]($element) 0]"
}
Run Code Online (Sandbox Code Playgroud)
但它返回:
can't read "thefilevalue_": no such variable
我在tcl 8.4,我不能升级它.
我该怎么办呢?
谢谢
我想构造一个复杂的变量,让我们看看:
set entry_arg [lindex $argv 1]
set command_to_launch {extrernal_command_tool -option "set var $entry_arg" -other_option}
exec $command_to_lauch
Run Code Online (Sandbox Code Playgroud)
命令启动,没问题......
但是,问题是该工具得到$ entry_arg并崩溃......这是由于""不允许tcl解释de变量
set command_to_launch {extrernal_command_tool -option "set var [lindex $argv 1]" -other_option}
Run Code Online (Sandbox Code Playgroud)
有同样的问题!
我该如何解决?