[Info-vax] COBOL, <gack!> again! Return status.
bill
bill.gunshannon at gmail.com
Mon Sep 11 16:15:56 EDT 2023
On 9/11/2023 3:59 PM, Arne Vajhøj wrote:
> On 9/11/2023 3:01 PM, Brian Schenkenberger wrote:
>> How does a COBOL program return a status (ie. R0) to a calling
>> program? I found a reference to RETURN-CODE but compiler balks at that.
>
> Disclaimer: I really don't know Cobol, but the following seems to work:
>
> $ type m.cob
> identification division.
> program-id.m.
> data division.
> working-storage section.
> 01 a pic 9(9) comp.
> 01 b pic 9(9) comp.
> 01 res pic 9(9) comp.
> 01 res2 pic 9(9) display.
> procedure division.
> main-paragraph.
> move 123 to a
> move 456 to b
> call "ADD2" using a,b giving res
> move res to res2
> display res2
> stop run.
> $ cob m
> $ type add2.cob
> identification division.
> program-id.add2.
> data division.
> working-storage section.
> 01 res pic 9(9) comp.
> linkage section.
> 01 a pic 9(9) comp.
> 01 b pic 9(9) comp.
> procedure division using a,b giving res.
> main-paragraph.
> compute res = a + b.
> end program add2.
> $ cob add2
> $ link m + add2
> $ run m
> 000000579
>
Yeah, that should do the trick. I prefer to use RETURNING rather than
GIVING but that's just a human readability thing for me.
bill
More information about the Info-vax
mailing list