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} } }
MG April 20th 2005 - In PHP, continue (and break) accept an argument that tells it how many nesting levels to continue/break for, slightly-similar to return's -code option. How hard would it be to add something like that into Tcl? Since neither break nor continue accept any arguments right now, as long as it defaulted to 1 it would have total backwards-compatability, and would, IMHO, be more "natural" than the above.
schlenk Did you try return -code continue -level ...
[ Tcl syntax help | Arts and crafts of Tcl-Tk programming | Category Command | Category Control Structure ]