home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!purdue!mentor.cc.purdue.edu!seaman.cc.purdue.edu!ags
- From: ags@seaman.cc.purdue.edu (Dave Seaman)
- Subject: Re: Jumping from nested subroutine to main directly?
- Message-ID: <By2xxC.JAB@mentor.cc.purdue.edu>
- Sender: news@mentor.cc.purdue.edu (USENET News)
- Organization: Purdue University
- References: <1992Nov21.015026.17820@netcom.com> <DODD.92Nov21071326@mycenae.cchem.berkeley.edu>
- Date: Sat, 21 Nov 1992 18:56:00 GMT
- Lines: 22
-
- >
- >>>>>> "John" == John H. Chauvin <jchauvin@netcom.com> writes:
- >
- > John> Is it possible to transfer control from a nested subroutine directly to the
- > John> main routine without have to execute multiple returns from all the
- > John> subroutines in between? I would like a way of exiting directly to the main
- > John> routine when a error is detected six or seven subroutines down.
-
- Write a subroutine to do whatever final cleanup is needed. Have
- the main program end with a call to the cleanup routine. Have the
- cleanup routine finish with a STOP statement, so that it never
- returns to the main program.
-
- Now, when an error is detected and you want to bail out, you can
- just call the cleanup routine, knowing it will never return. You
- can even have the routine take an error argument to indicate the
- reason for termination, and have the cleanup take appropriate
- action.
-
- --
- Dave Seaman
- ags@seaman.cc.purdue.edu
-