Version 5 of continue

Updated 2005-04-20 10:08:13

http://purl.org/tcl/home/man/tcl8.4/TclCmd/continue.htm


Suppose the following code:

 foreach  i  $List1  { 

     foreach  j  $List2  { 

        if  [some condition] {continue}

        eval {blah blah blah}
     }
 }

Continue interrupts the foreach j loop. But what if I wanted it to break the foreach i loop?

Place the [foreach i] command in a proc and use return instead of continue.

Lars H: Or use breakeval as follows

  foreach i $List1 { 
     breakeval-aware foreach j $List2 { 

        if  {[some condition]} then {
           breakeval {continue} ; # Break out of j loop, do a continue for the i loop.
        }

        eval {blah blah blah}
     }
 }

[ Tcl syntax help | Arts and crafts of Tcl-Tk programming | Category Command | Category Control Structure ]