小编hey*_*hey的帖子

tcl中的棘手的var验证

根据我的输入,我有一个存在或不存在的变量,所以我做了一个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)

怎么了?

tcl

2
推荐指数
1
解决办法
101
查看次数

如何替换数组名称中的变量?

我们假设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,我不能升级它.

我该怎么办呢?

谢谢

arrays tcl

0
推荐指数
1
解决办法
858
查看次数

如何在TCL的字符串列表中解释""?

我想构造一个复杂的变量,让我们看看:

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)

有同样的问题!

我该如何解决?

tcl

0
推荐指数
1
解决办法
172
查看次数

标签 统计

tcl ×3

arrays ×1