Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 1.30 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Breaking parent loop in tcl
  2. while {[gets $thefile line] >= 0} {
  3.    for {set i 1} {$i<$count_table} {incr i} {
  4.    if { [regexp "pattern_$i" $line] } {
  5.       for {set break_lines 1} {$break_lines<$nb_lines} {incr break_lines} {
  6.          if {[gets $thefile line_$break_lines] < 0} break
  7.       }
  8.    }
  9.    #some other process to do
  10. }
  11.        
  12. proc magictrap {code body} {
  13.     if {$code <= 4} {error "bad magic code"}; # Lower values reserved for Tcl
  14.     if {[catch {uplevel 1 $body} msg opt] == $code} return
  15.     return -options $opt $msg
  16. }
  17. proc magicthrow code {return -code $code "doesn't matter what this is"}
  18.  
  19. while {[gets $thefile line] >= 0} {
  20.    magictrap 5 {
  21.       for {set i 1} {$i<$count_table} {incr i} {
  22.          if { [regexp "pattern_$i" $line] } {
  23.             for {set break_lines 1} {$break_lines<$nb_lines} {incr break_lines} {
  24.                if {[gets $thefile line_$break_lines] < 0} {magicthrow 5}
  25.             }
  26.          }
  27.       }
  28.    }
  29.    #some other process to do
  30. }
  31.        
  32. while {[gets $thefile line] >= 0} {
  33.   set go_on 1
  34.   for {set i 1} {$i<$count_table && $go_on} {incr i} {
  35.     if { [regexp "pattern_$i" $line] } {
  36.       for {set break_lines 1} {$break_lines<$nb_lines && $go_on} {incr break_lines} {
  37.         if {[gets $thefile line_$break_lines] < 0} { set go_on 0 }
  38.       }
  39.      }
  40.    }
  41.    #some other process to do
  42. }