Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!eru!luth!sunic!mcsun!isgate!krafla!aries From: aries@rhi.hi.is (Reynir Hugason) Newsgroups: comp.sys.mac.programmer Subject: Re: Breaking out of a series of routines Message-ID: <1838@krafla.rhi.hi.is> Date: 10 Jul 90 20:20:53 GMT References: <25526@cs.yale.edu> <5252@plains.UUCP> <2745.2699a0d0@cc.helsinki.fi> Organization: University of Iceland Lines: 54 >On an error condition I wish to immediately stop processing a large file >and break out of about 10 routines that have been calling each other and >return to my main event loop. Is there any way to do this without >passing and error flag to each of the calling routines? Here is an examplery clean way of doing it, assuming you're using Pascal 8) UNIT FileReader; INTERFACE USES ... PROCEDURE ReadFile; FUNCTION Status: INTEGER; ... and so on ... IMPLEMENTATION VAR errFlag: INTEGER; PROCEDURE ReadFile; PROCEDURE CheckError; BEGIN IF (errFlag <> noErr) THEN BEGIN { Clean-up now } EXIT(ReadFile); END; END; { Here come your procedures for reading the file } BEGIN { Initiate sequence } END; FUNCTION Status: INTEGER; BEGIN Status:=errFlag; END; END. --- Well that's it, now try to do that in C !!! 8) Mimir (aries@rhi.hi.is) - Aries Software, Inc.