COBOL can pass and receive return codes from other programs.
Restriction: The following applies to native COBOL only.
Most languages are capable of passing a return code back to the calling program. COBOL can pass and receive them as follows:
- To receive a return code from a non-COBOL program, use the RETURNING phrase in the CALL statement in the calling COBOL program.
- To pass a return code back from a COBOL program, use the RETURNING phrase of the EXIT PROGRAM, GOBACK, or STOP RUN statement.
The RETURNING phrase enables you to define the format of the return code yourself and so cope with whatever size of return code you require.
The registers used to pass the return code from COBOL and Microsoft C are:
32-bit Intel Return Code Size
|
Register
|
One byte
|
AL
|
Two bytes
|
AX
|
Four bytes
|
EAX
|
X64 Return Code Size
|
Register
|
One, two, and four bytes
|
as for X86
|
Eight bytes
|
RAX
|
IA64 Return Code Size
|
Register
|
Any size
|
R8
|