opencobol - Call function in COBOL more than once -


i have main calling 2 functions. second function called (decrypt) calls first function (encrypt) inside of it. here encrypt being called twice. once in main, , once inside of decrypt.

the issue refuses work way. once encrypt gets used in main, can't use encrypt again anywhere~ in program. variables still in use , can't pass new ones.

for example, if remove encrypt main function , call decrypt - works fine. can't figure out why.

identification division. program-id. caeser-1-cipher. data division. procedure division call 'encrypt' using content inpute ciphere. call 'decrypt' using content inputd cipherd. stop run.  identification division. program-id. encrypt. data division. procedure division blah blah blah blah compute end program encrypt.  identification division. program-id. decrypt. data division. procedure division blah blah call 'encrypt' using content blah blah exit program. end program decrypt. 

i'm not sure follow question completely, have expeced more problems decrypt. why...

program ser-1-cipher contains 2 nested programs: encrypt , decrypt. until declare encrypt , decrypt common programs cannot "see" each other because programs @ higher levels of nesting (eg. ser-1-cipher) can "see" programs nested within them. explained in open cobol programmers guide on nested programs.

try declaring nested programs as:

 program-id. encrypt common.  program-id. decrypt common. 

this way program decrypt able call encrypt.

next, encourage use goback in place of stop run , exit program when returning control operating system or calling programs. opencobol programmers guide makes recommendation.

finally, each subprogram should contain last statement goback. not sure behaviour of encrypt without having explicit return statement of kind. actual program may have this, code example in question doesn't.

open cobol not seem have restrictions on having recursion among nested programs, versions of cobol not allow (eg. ibm enterprise cobol).


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -