Exit mid-loop

Topics related to the use of Oberon language features
Locked
Helpdesk
Posts: 40
Joined: Sat Jan 01, 2011 5:43 am
Contact:

Exit mid-loop

Post by Helpdesk » Fri Apr 01, 2011 12:15 pm

What is the 'correct' way to exit a REPEAT...UNTIL loop?

Code: Select all

REPEAT
  ...
  ...
  IF Error THEN exit;    (* Leave the room NOW!! *)
  ....
  ....
UNTIL ...
Not appropriate to check at the beginning of the loop as Error hasn't yet
occurred.
Can't continue with the loop to UNTIL as I have an Error.

cfbsoftware
Site Admin
Posts: 533
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: Exit mid-loop

Post by cfbsoftware » Fri Apr 01, 2011 12:43 pm

Code: Select all

  REPEAT
    ...
    IF ~error THEN
      ...
    END
  UNTIL ... OR error;

Locked