Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!tut!hydra!hylka!mnykanen From: mnykanen@cc.helsinki.fi Newsgroups: comp.sys.mac.programmer Subject: Re: Breaking out of a series of routines Message-ID: <2745.2699a0d0@cc.helsinki.fi> Date: 10 Jul 90 09:33:04 GMT References: <25526@cs.yale.edu> <5252@plains.UUCP> Organization: University of Helsinki Lines: 28 In article <5252@plains.UUCP>, puklich@plains.UUCP (Blayne Puklich) writes: > tarr-michael@CS.Yale.EDU (michael tarr) wrote in article Breaking out of a > series of routines: >>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? .stuff on C's set/longjmp() deleted.. > If you're using Pascal, probably a good way to do this is to pass a return > code back up through each function (make them functions). Then each and > every call to the functions would be a test for a return code. This really > isn't as painful as it may seem like. Pascal function return values are > generally placed in a register (D0 if I remember right), so a test wouldn't > be too time-consuming. In Pascal a GOTO (yuck!) should suffice, at least as defined in the standard. Since a Pascal GOTO is *not* just a branch instruction (it even manages the run-time stack frames!) many microcomputer compilers do not conform, though. But I too recommend functions returning error codes on aesthetic grounds: they would make error recovery a part of normal program behaviour, not 'an act of god' miraculously affecting the control flow. -- Matti Nyk{nen CS Student at Helsinki U, Finland email: mnykanen@cc.helsinki.FI The best opinions available; get them while they're hot!