当我 运行 我的 TCL 脚本时,有没有办法用我的 运行 命令添加命令或变量?
when I run my TCL script is there a way I can add a command or a variable with my run command?
我想做的是 运行 我的带变量的 TCL 脚本。
例如,假设我的脚本名为 example.tcl。
我希望能够 运行 该脚本执行如下操作:
tclsh example.tcl success
然后在我的 tcl 脚本中我将有:
set status = variable <---- this variable should be equal to "success"
puts $status
反正在TCL我可以做这样的事情吗?
脚本名称后 tclsh
的参数作为列表存储在全局 argv
变量中。
set status [lindex $argv 0]
puts "status = $status"
列表的长度在 argc
中,但没有人真正使用它。脚本在argv0
,不在argv
;有时候很方便。
我想做的是 运行 我的带变量的 TCL 脚本。
例如,假设我的脚本名为 example.tcl。
我希望能够 运行 该脚本执行如下操作:
tclsh example.tcl success
然后在我的 tcl 脚本中我将有:
set status = variable <---- this variable should be equal to "success"
puts $status
反正在TCL我可以做这样的事情吗?
脚本名称后 tclsh
的参数作为列表存储在全局 argv
变量中。
set status [lindex $argv 0]
puts "status = $status"
列表的长度在 argc
中,但没有人真正使用它。脚本在argv0
,不在argv
;有时候很方便。