On Thu, 10 Aug 2017 07:04:02 -0500, John Mckown
(john.archie.mck...@gmail.com) wrote about "Re: COBOL STOP RUN
enhancement" (in
<CAAJSdjj4ZxbhMEM1W5mrw-JYMyQqcbs=gy+gao_slk2ogga...@mail.gmail.com>):

> On Wed, Aug 9, 2017 at 6:43 PM, Frank Swarbrick <frank.swarbr...@outlook.com
>> wrote:
[snip]
>> Anyway it seems to me that an "official" COBOL method of doing this could
>> be worthwhile.  I don't know if other languages such as C or PL/I have
>> something similar.  All thoughts are welcome (preferably agreeing with me
>> <grin>).
>>
> ​PL/I has the STOP statement. But it is like COBOL's STOP RUN in that it
> does not have any specification for a return code.

PL/I has the PLIRETC() built-in subroutine that is directly analogous to
MOVE nn TO RETURN-CODE in COBOL. Moreover, the STOP statement adds 1000
to the return code. Thus,

        CALL PLIRETC(16);
        STOP;

will terminate the step normally with a return code of 1016.

One can also use SIGNAL FINISH to terminate without adding to the return
code.

> C can use the exit()
> function, which can take an integer value which is the return code. But
> nothing has the equivalent of the 'ERROR STATUS' functionality that you
> mentioned.

The exit() function poses problems when using C++, as it bypasses static
destructors.

To set a return code more safely in C/C++, one should use a return
statement in the main() function with a numeric value:

int main(void)
{
   ...
   return 16;
}

The return type of "int" is mandatory in this case.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to