在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 5321|回复: 7

[求助] TCL的proc参数为输出一个文件,那么如何定义该proc的help?

[复制链接]
发表于 2013-12-10 15:08:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
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。
发表于 2013-12-10 19:38:25 | 显示全部楼层
回复 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 选项的功能吗?
 楼主| 发表于 2013-12-11 09:23:14 | 显示全部楼层
回复 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信息。
发表于 2013-12-11 13:07:17 | 显示全部楼层




   proc定义行的参数格式有问题,你参考 http://www.doc88.com/p-711614312250.html 这个文章的第4页。
 楼主| 发表于 2013-12-11 14:53:22 | 显示全部楼层
回复 4# sjtusonic


   没看出来有什么问题啊,我一般都是这样写的
proc procName {var1 var2 ..} {
   body
}
发表于 2013-12-11 20:01:23 | 显示全部楼层
本帖最后由 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这四个字母。
 楼主| 发表于 2013-12-12 09:52:10 | 显示全部楼层
回复 6# sjtusonic


   多谢,明白了。一个参数时,就忘记写这个parse_args ...了。。
发表于 2014-7-22 23:17:02 | 显示全部楼层
能回答下我这个脚本是什么意思吗?
set tmpfile tmpfile[pid] [expr int (rand()*10000)]
谢谢啦
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-3-29 07:02 , Processed in 0.028470 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表