【发布时间】:2014-03-14 16:15:15
【问题描述】:
我有两个必须来回传递变量的嵌入式 Tcl 脚本(main.tcl、secondary.tcl)。根据main.tcl 在运行secondary.tcl 之前的结果,必须更改secondary.tcl 中的某些预定义变量。然后secondary.tcl 必须将一些变量传递给main.tcl 来定义如何继续。
例子:
#main.tcl
# Here there is first some script which give some results
# Let's say for now result==0 or 1 and some variable "res"
if { result==0 } {
set var1 $res
} else {
set var2 $res
}
# Depending on which of the variables is set, the corresponding
# variable should be altered in secondary.tcl
source /path/to/secondary.tcl
# Now the result in secondary.tcl has to be inserted in this tcl-script
set res_sec $result_secondary
# Rest of script is executed
辅助 tcl 脚本如下所示
#secondary.tcl
set var1 some_value1
set var2 some_value2
# Rest of script is executed
set result_secondary some_result ;# This variable has to be passed to main.tcl
# End of script
我希望很清楚我想要做什么。我知道在某些 tcl 脚本中,他们使用“参数”然后使用:secondary.tcl -parameters "var1 $res" 只会在secondary.tcl 中更改var1。但我不知道该怎么做。
【问题讨论】:
标签: variables tcl argument-passing