home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!uwm.edu!spool.mu.edu!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!burley
- From: burley@apple-gunkies.gnu.ai.mit.edu (Craig Burley)
- Newsgroups: comp.lang.fortran
- Subject: Re: Multiple returns (was: Jumping from nested subs to main directly)
- Date: 23 Nov 92 11:08:26
- Organization: Free Software Foundation 545 Tech Square Cambridge, MA 02139
- Lines: 54
- Message-ID: <BURLEY.92Nov23110826@apple-gunkies.gnu.ai.mit.edu>
- References: <1992Nov23.021053.11218@netcom.com>
- NNTP-Posting-Host: apple-gunkies.gnu.ai.mit.edu
- In-reply-to: jchauvin@netcom.com's message of Mon, 23 Nov 1992 02:10:53 GMT
-
- In article <1992Nov23.021053.11218@netcom.com> jchauvin@netcom.com (John H. Chauvin) writes:
-
- PROGRAM EXAMPLE
- CALL SUB1
- .
- .
- .
- STOP
- END
- SUB1
- CALL SUB2
- A=A+1
- END
- SUB2
- CALL SUB3
- END
- SUB3
-
- EXIT 2 (Returned to statement A=A+1 in one call)
-
- END
-
- Why won't RETURN work? It'll return to the END in SUB2, which'll return
- to A=A+1 in SUB1.
-
- Now, if you meant to imply that SUB2's call to SUB3 might be followed by
- other stuff you don't want to happen...try this:
-
- PROGRAM EXAMPLE
- CALL SUB1
- .
- .
- .
- STOP
- END
- SUBROUTINE SUB1
- CALL SUB2
- A=A+1
- END
- SUBROUTINE SUB2
- CALL SUB3(*99)
- ...other stuff I don't want to happen if SUB3 wants to "jump" back to SUB1
- 99 END
- SUBROUTINE SUB3(*)
-
- RETURN 1 (Return to statement label passed for first "*" in arglist)
-
- END
-
- I hope this helps.
- --
-
- James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
- Member of the League for Programming Freedom (LPF) lpf@uunet.uu.net
-