I'm not sure I follow your question completely, I would have expeced more problems with DECRYPT
. This is why...
Program SER-1-CIPHER
contains two nested programs: ENCRYPT
and DECRYPT
. Until you
declare ENCRYPT
and DECRYPT
as COMMON
programs they cannot "see" each other because only programs
at higher levels of nesting (eg. SER-1-CIPHER
) can "see" programs that are nested within them. This is explained in the Open Cobol Programmers Guide on nested programs.
Try declaring nested programs as:
PROGRAM-ID. ENCRYPT IS COMMON.
PROGRAM-ID. DECRYPT IS COMMON.
This way program DECRYPT will be able to CALL ENCRYPT.
Next, I would encourage you to use GOBACK
in place of STOP RUN
and EXIT PROGRAM
when returning control to the operating system or
calling programs. The OpenCobol Programmers Guide also makes this recommendation.
Finally, each subprogram should contain as its last statement a GOBACK
. I am not sure what the behaviour of ENCRYPT
is without
having an explicit return statement of some kind. Your actual program may have this, but the code example in your question doesn't.
Open Cobol does not seem to have any restrictions on having recursion among nested programs, but some versions of COBOL do not allow this (eg. IBM Enterprise COBOL).