Re: Stop Run vs GoBack




"Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5e880dF37scomU1@xxxxxxxxxxxxxxxxxxxxx

"William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx> wrote in message
news:IPyfi.318341$dg3.215593@xxxxxxxxxxxxxxxxxxxxxxxxx
(new thread, "old" topic)

Facts and Options inter-mixed:

1) GoBack is in the '02 Standard (but not any earlier ones).

2) In previous (pre-02) Standards, it was "non-conforming" (but often
accepted as an extension) to code an EXIT Program immediately followed by a
Stop Run.

3) COBOL (unlike many - possibly MOST - other languages) does NOT require you
to "declare" a program as either a "MAIN" or "SUB" at compile time. (Having a
LINKAGE section *implies* that you are a subprogram, but that is neither
required nor universally even true if you access the fields in it).

4) For as long as I have been involved in IBM mainframe (mostly MVS)
programming, the use of GOBACK "universally" instead of Stop Run and Exit
Program has been recommended by most shops (and classes). (As mentioned
elsewhere - at one time it was REQUIRED for CICS and some IMS programming).

5) Use of STOP RUN in a DECLARATIVE (or ABEND routine) is medium common. This
means that when the situation occurs, one wants the application to STOP - no
matter whether it is "sub" or "main".

6) The "biggest" issue with GoBack (IMHO) has to do with "multi-language"
applications. It is a little unclear where a GoBack takes you - to the
CALLing non-COBOL system or to the operating system. IBM even changed this
(at one stage) with VS COBOL II - although it is now back to the
"traditional" return to the CALLing program (or CLASS/Method - in the case of
OO).

***

Personally, I can't see any reason NOT to "universally" use GOBACK - (except
to require immediate application termination). However, if you want
"portable" code to non-IBM compatible (and pre '02 Standard) applications,
you might want to think twice about it.

...or even use STOP RUN in main programs and GOBACK in called ones, in the
certain knowledge that your code will then behave correctly on any COBOL
platform, including PCs, and that you have complied with the "spirit" of COBOL
in making your code semantically accurate. (People for whom IBM is the World,
may see it differently.)

(Of course, if you decide to make a called program a main one, or vice versa,
then you will have to amend the code, and test it, but you would've done that
anyway before promoting it to live, right? :-))

Pete.



Well, NO - you wouldn't have to test it if you design (from scratch) a program
to be usable as BOTH a main and SUB program. This can be done on an IBM
platform (or with any of the MULTI-IBM compatible compilers such as Fujitsu,
Micro Focus, RM - and any '02 conforming compiler) by using GOBACK.

For compilers allowing an extension to the '85 Standard which allows EXIT
PROGRAM to be followed (immediately) by STOP RUN, then code:

Exit Program
Stop Run

of course, unlike GOBACK this may not work within a Method or user-defined
function. Therefore, as I said before, use GOBACK unless you REALLY think your
code will ever be compiled on a system without support for it.

P.S. GoBack within a METHOD or FUNCTION avoids needing to know which type of
"procedural" (i.e Procedure Division) your code is in. This allows for "common
code" to be brought in via a COPY statement (without REPLACING).

--
Bill Klein
wmklein <at> ix.netcom.com


.



Relevant Pages

  • Re: COBOL record length on z/series
    ... I currently always use GOBACK in new programs. ... But in IBM ... You definitely do *not* want to use EXIT PROGRAM only in a main program, ... If it's a sub-program it will hit the EXIT PROGRAM and return to the caller. ...
    (comp.lang.cobol)
  • Re: Report enhancements
    ... William M. Klein wrote: ... What was the logic of making the EXIT PROGRAM STOP RUN sequence illegal? ... allowed to use GOBACK but that may be faulty memory. ...
    (comp.lang.cobol)
  • Re: COBOL record length on z/series
    ... I currently always use GOBACK in new programs. ... I used to use EXIT PROGRAM mostly, ... But in IBM ... I didn't know you could use GOBACK in a main program in IBM environments, ...
    (comp.lang.cobol)
  • Re: Report enhancements
    ... First of all GOBACK was not part of the '85 standard. ... disallowed' or doesn't execute these two in sequence, ... in a pargarph of its own) extending to EXIT PROGRAM was a mistake? ...
    (comp.lang.cobol)
  • Re: Stop Run vs GoBack
    ... platform (or with any of the MULTI-IBM compatible compilers such as Fujitsu, ... RM - and any '02 conforming compiler) by using GOBACK. ... While one can design a program to be both a MAIN or a SUB it is ... 'COPYed' procedure code is very poor design. ...
    (comp.lang.cobol)