当我运行TCL脚本时,有没有一种方法可以使用run命令添加命令或变量?

当我运行TCL脚本时,有没有一种方法可以使用run命令添加命令或变量?,tcl,Tcl,我要做的是用一个变量运行我的TCL脚本 set status [lindex $argv 0] puts "status = $status" 例如,让我们假设我的脚本名为example.tcl 我希望能够运行这样的脚本: tclsh example.tcl success 然后在我的tcl脚本中,我将有: set status = variable <---- this variable should be equal to "success&quo

我要做的是用一个变量运行我的TCL脚本

set status [lindex $argv 0]
puts "status = $status"
例如,让我们假设我的脚本名为example.tcl

我希望能够运行这样的脚本:

tclsh example.tcl success 
然后在我的tcl脚本中,我将有:

set status = variable  <---- this variable should be equal to "success"
puts $status 

set status=variable脚本名后的
tclsh
参数作为列表存储在全局
argv
变量中

set status [lindex $argv 0]
puts "status = $status"

列表的长度在argc中,但是没有人真正使用它。脚本位于
argv0
,而不是
argv
;这有时非常方便。

脚本名后的
tclsh
参数作为列表存储在全局
argv
变量中

set status [lindex $argv 0]
puts "status = $status"
列表的长度在argc中,但是没有人真正使用它。脚本位于
argv0
,而不是
argv
;有时候这很方便