
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 1.30 KB | hits: 8 | expires: Never
Breaking parent loop in tcl
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
}
proc magictrap {code body} {
if {$code <= 4} {error "bad magic code"}; # Lower values reserved for Tcl
if {[catch {uplevel 1 $body} msg opt] == $code} return
return -options $opt $msg
}
proc magicthrow code {return -code $code "doesn't matter what this is"}
while {[gets $thefile line] >= 0} {
magictrap 5 {
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} {magicthrow 5}
}
}
}
}
#some other process to do
}
while {[gets $thefile line] >= 0} {
set go_on 1
for {set i 1} {$i<$count_table && $go_on} {incr i} {
if { [regexp "pattern_$i" $line] } {
for {set break_lines 1} {$break_lines<$nb_lines && $go_on} {incr break_lines} {
if {[gets $thefile line_$break_lines] < 0} { set go_on 0 }
}
}
}
#some other process to do
}