Re: invoked "break" outside of a loop
- From: "Gerald W. Lester" <Gerald.Lester@xxxxxxx>
- Date: Sat, 23 Sep 2006 00:32:50 -0500
Russell Trleleaven wrote:
Gerald W. Lester wrote:Russell Trleleaven wrote:set numbers [ list 0 1 2 3 4 5 6 7 8 9 ]
proc foo {} {
#return break
#uplevel break
#namespace eval :: break
return -code break
}
foreach number $numbers {
if { $a == 3 } { foo }
puts $a
}
return break in foo gets me "invoked "break" outside of a loop"
uplevel break does the same.
namespace eval :: break does the same.
return -code break does what I want.
Should any of the first three approaches work like the fourth?
Sincerely,
russ@xxxxxxxx
Funny, when I run the above code I get:
can't read "a": no such variable
Now if I run:
proc foo {} {
#return break
#uplevel break
#namespace eval :: break
return -code break
}
foreach a $numbers {
if { $a == 3 } { foo }
puts $a
}
I get:
0
1
2
with no error.
Yes I made an error
Sorry to belabor the point but I was hoping someone would explain why
"break"
"uplevel break"
and
"namespace eval :: break"
don't work like I thought they might.
Maybe if you explained why you would think that they would work we may be able to tell you where you are going wrong.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.
- References:
- invoked "break" outside of a loop
- From: Russell Trleleaven
- Re: invoked "break" outside of a loop
- From: Gerald W. Lester
- Re: invoked "break" outside of a loop
- From: Russell Trleleaven
- invoked "break" outside of a loop
- Prev by Date: Re: brace {} and quote "" effect on outmost?
- Next by Date: Re: How to run tcl in ActiveTcl Windows?
- Previous by thread: Re: invoked "break" outside of a loop
- Next by thread: Re: invoked "break" outside of a loop
- Index(es):
Relevant Pages
|