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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2539|回复: 3

[求助] icc while 问题

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

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

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

x
本人初学tcl,遇到问题请大神帮忙解答

脚本功能:使用while 循环形势复制一个文件

#
set sf_input [ open in.txt r ]
set sf_output [ open out.txt w ]

while { [ gets $sf_input line ] } {
puts $sf_output $line
}

close $sf_input
close $sf_output

执行这个脚本时,while 循环不能退出,好像是进入了死循环,麻烦帮忙分析下那里出问题了
发表于 2013-10-16 15:12:15 | 显示全部楼层
回复 1# wenjian07


   
while {[gets $chan line] >= 0} {
    puts "[incr lineNumber]: $line"
}
while条件中加上 >=0 即可
 楼主| 发表于 2013-10-16 15:30:34 | 显示全部楼层
回复 2# sjtusonic


    为什么我写的不行呢,input文件中没有空白行,gets第一次执行应该得到的应该就是>0的数阿
发表于 2013-10-16 18:44:10 | 显示全部楼层
回复 3# wenjian07


    If end of file occurs while scanning for an end of line, the command returns whatever input is available up to the end of file. If channelId is in non-blocking mode and there is not a full line of input available, the command returns an empty string and does not consume any input. If varName is specified and an empty string is returned in varName because of end-of-file or because of insufficient data in non-blocking mode, then the return count is -1. Note that if varName is not specified then the end-of-file and no-full-line-available cases can produce the same results as if there were an input line consisting only of the end-of-line character(s). The eof and fblocked commands can be used to distinguish these three cases.


你看看有没有帮助
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

×

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

GMT+8, 2024-4-18 08:25 , Processed in 0.021886 second(s), 9 queries , Gzip On, Redis On.

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