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

bill bill.gunshannon at gmail.com
Mon Sep 11 22:04:57 EDT 2023



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.





More information about the Info-vax mailing list