【发布时间】:2012-07-16 10:18:31
【问题描述】:
我在 while 循环中有一个 for 循环。我有一个条件来打破 for 循环中的 while。
代码如下:
while {[gets $thefile line] >= 0} {
for {set i 1} {$i<$count_table} {incr i} {
if { [regexp "pattern_$i" $line] } {
for {set break_lines 1} {$break_lines<$nb_lines} {incr break_lines} {
if {[gets $thefile line_$break_lines] < 0} break
}
}
#some other process to do
}
我想跳过解析文件中的$nb_lines 以进一步做其他事情。这里的break,打破了for循环,所以它不起作用。
for 循环可以破坏 while 循环吗? 但是中断仅针对 1 行(或更多)行,我想在中断后继续解析文件以进一步处理行
谢谢
【问题讨论】:
标签: for-loop while-loop tcl