【发布时间】:2016-01-30 13:02:08
【问题描述】:
我有一个示例过程
proc exam {return_value} {
set input "This is my world"
regexp {(This) (is) (my) (world)} $input all a b c d
set x "$a $b $c $d"
return x }
在执行上述 proc 之后,我将在单个列表中获得所有 a b c d 值,所以如果我只想要上述 proc 中的 b 值,现在正在执行 [lindex [exam] 1]。 我正在寻找其他方式以不同的方式获取输出,而不是使用 lindex 或 returun_value(b) 可以提供我预期的输出
【问题讨论】:
-
请澄清您的问题。你到底在找什么?你认为你应该怎么做才能得到你想要的?像
[exam b]这样的东西只返回$b和[exam d]只返回$d或者[exam a b]来返回一个列表$a $b? -
没有@jerry 这不是故意的,我期待“[exam 1st_run]”。在这种情况下,在 proc 执行之后如果我想获取存储在 b 中的值。例如,如果我执行' puts $1st_run(b)' 它应该有 "is" 谢谢你的帮助
标签: arrays list return tcl proc