Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is break broken? :) :) :)

13 views
Skip to first unread message

Brian T. Matchick

unread,
May 15, 1996, 3:00:00 AM5/15/96
to

I've started writing some expect scripts and have run into a little problem.
Mind you, I only have the O'Reilly Expect book, not Tcl, yet. :) Anyhow, I'm
trying to use break from within a nested loop (for inside a while) and
instead of
just exiting from in inner loop and moving on to the next command, it seems to
'continue' the outer while loop as well.

Is this right? Does break act funny with nested loops or should it work
just like
I'd think, just break out of the current loop (nested or not) and that's it?

Thanks for any info!

Brian

--
Brian Matchick
Pencom Systems Administration
matc...@pencom.com

And what is good, Phædrus,
And what is not good-
Need we ask anyone to tell us these things?

Robert M. Pirsig,
"Zen and the Art of Motorcycle Maintenance"

John Haxby

unread,
May 16, 1996, 3:00:00 AM5/16/96
to

Brian T. Matchick wrote:
>
> I've started writing some expect scripts and have run into a little problem.
> Mind you, I only have the O'Reilly Expect book, not Tcl, yet. :) Anyhow, I'm
> trying to use break from within a nested loop (for inside a while) and
> instead of
> just exiting from in inner loop and moving on to the next command, it seems to
> 'continue' the outer while loop as well.

The simplest example I could think of works:

while 1 {
puts hello
for {} 1 {} {
puts there
break
}
puts again
break
}

If "break" forced a continue of the while loop, you'd get "hello there
hello again", but I get "hello there again", which is what I expected.

--
John Haxby
These are my opinions, not my employer's.

0 new messages