如何获取过程接受的参数数量? [英] How to get the number of parameters that procedure accepts?
本文介绍了如何获取过程接受的参数数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
TCL 有没有办法获取程序接受的参数数量?例如我们有程序:
Is there a way in TCL to get the number of parameters that procedure accepts? For example we have procedure:
proc func {a} {
puts $a
}
我需要一种方法来将 func
过程接受的参数数量置于变量中.
I need a way to put in variable the number of parameters that func
procedure accepts.
推荐答案
您可以尝试以下方法:
info args func
这将获得 func
需要的参数.
This will get the arguments that func
require.
然后你可以用它来获取参数的数量:
Then you can use it to get the number of arguments:
set num [llength [info args func]]
在您的情况下,$num
将为 1.
In your case, $num
will be 1.
这篇关于如何获取过程接受的参数数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文