EETOP 创芯网论坛 (原名:电子顶级开发网)

标题: TCL的proc参数为输出一个文件,那么如何定义该proc的help? [打印本页]

作者: wjchuan    时间: 2013-12-10 15:08
标题: TCL的proc参数为输出一个文件,那么如何定义该proc的help?
TCL的proc参数为输出一个文件,那么如何定义该proc的help?

比如我定义的proc为 fix,参数为output(一个输出文件)。

然后,最后定义
define_proc_attributes fix -info "fix: fix file_name" \
    -define_args {
         {-help          "help information" "" string  optional}
    }


使用 fix -help时,会输出一个 -help的文件,并不是help。
作者: sjtusonic    时间: 2013-12-10 19:38
回复 1# wjchuan


   
-info info_text



Provides a help string for the procedure. This is printed by the help command when you request help for the procedure. If you do not specify info_text, the default is "Procedure".


你是需要这种 -info 选项的功能吗?
作者: wjchuan    时间: 2013-12-11 09:23
回复 2# sjtusonic

我的脚本是这样的:proc fix { output } {
    set fileId [open $output w 0750]
     .....
    puts  $fileId "######"
     ......
}



define_proc_attributes fix -info "fix: fix file_name"


使用 fix -help时,会输出一个 -help的文件,并不是提示的 info信息。
作者: sjtusonic    时间: 2013-12-11 13:07


   
回复  sjtusonic

我的脚本是这样的:proc fix { output } {
    set fileId [open $output w 0750]
  ...
wjchuan 发表于 2013-12-11 09:23




   proc定义行的参数格式有问题,你参考 http://www.doc88.com/p-711614312250.html 这个文章的第4页。
作者: wjchuan    时间: 2013-12-11 14:53
回复 4# sjtusonic


   没看出来有什么问题啊,我一般都是这样写的
proc procName {var1 var2 ..} {
   body
}
作者: sjtusonic    时间: 2013-12-11 20:01
本帖最后由 sjtusonic 于 2013-12-11 20:02 编辑


   
回复  sjtusonic


   没看出来有什么问题啊,我一般都是这样写的
proc procName {var1 var2 ..} {
  ...
wjchuan 发表于 2013-12-11 14:53




    应该写成:
proc fix args {
     parse_args ...
     set fileId [open $output w 0750]
      .....
     puts  $fileId "######"
      ......
}

define_proc_attributes fix -info "fix: fix file_name"


以上的args就是指args这四个字母。
作者: wjchuan    时间: 2013-12-12 09:52
回复 6# sjtusonic


   多谢,明白了。一个参数时,就忘记写这个parse_args ...了。。
作者: 永不止步wl    时间: 2014-7-22 23:17
能回答下我这个脚本是什么意思吗?
set tmpfile tmpfile[pid] [expr int (rand()*10000)]
谢谢啦




欢迎光临 EETOP 创芯网论坛 (原名:电子顶级开发网) (https://bbs.eetop.cn/) Powered by Discuz! X3.5