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

bill bill.gunshannon at gmail.com
Tue Sep 12 08:26:49 EDT 2023


On 9/11/2023 10:04 PM, bill wrote:
> 
> 
> And here is the definitive answer.  And based on how convoluted
> it seems I can understand why the method I provide in my last
> example is considered the better way and none of the numerous
> COBOL books (including Murach!) even mention it.  But it does
> work.  Another advantage of the other way is you can actually
> return more than one value.
> 
> bill
> 
> 
> 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 RETURNING res.
>       move res to res2
>       display res2
>       stop run.
> 
> 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.
> main-paragraph.
>       compute res = a + b.
>       move res to RETURN-CODE.
>       end program add2.
> 
> 

And, just to throw another monkey wrench into the works,
I read the VA COBOL Reference and the VSI OpenVMS COBOL
Reference and it appears that VMS COBOL does not even
support RETURNING/GIVING in call statements so the example
above will probably not even compile.  But, the previous
example provided should work fine and seems to be the way
VMS expects it to be done.  Hope it helps, Brian.

bill

[Anybody else got some COBOL that needs fixin?  I still
love this stuff.]






More information about the Info-vax mailing list