[Info-vax] COBOL, <gack!> again! Return status.

Brian Schenkenberger mail at SendSpamHere.ORG
Mon Sep 11 16:12:28 EDT 2023


On 2023-09-11 19:59:05 +0000, Arne Vajhj said:

> 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
> 
> Arne

I've tried that but compiler pukes on it.  I've tried:

MOVE SS$_NORMAL TO RES.

and

COMPUTE RES = SS$_NORMAL *1.

It just doesn't like it.

—VAXman




More information about the Info-vax mailing list