Skip to main content
A LONG time ago we used the GLOBAL clause in the FD's of native .exes so that the .exe controlled the OPEN and CLOSE of files and called .dlls just read and wrote them. UNFORTUNATELY, that code was lost to the mists of time. Today we want to resurrect that functionality, but in Managed COBOL. I've put together an .exe that has FD LOG-FILE IS GLOBAL and does OPEN, WRITE, invokes a .dll, WRITEs again, and CLOSEs. The .dll (class) has FD LOG-FILE and does a write, no OPEN or CLOSE. Everything works in VS Debug mode until the WRITE in the .dll, which gets a 4/8 File Status and "148 Wrong open mode or access mode for write". Does anybody know what I forgot?
A LONG time ago we used the GLOBAL clause in the FD's of native .exes so that the .exe controlled the OPEN and CLOSE of files and called .dlls just read and wrote them. UNFORTUNATELY, that code was lost to the mists of time. Today we want to resurrect that functionality, but in Managed COBOL. I've put together an .exe that has FD LOG-FILE IS GLOBAL and does OPEN, WRITE, invokes a .dll, WRITEs again, and CLOSEs. The .dll (class) has FD LOG-FILE and does a write, no OPEN or CLOSE. Everything works in VS Debug mode until the WRITE in the .dll, which gets a 4/8 File Status and "148 Wrong open mode or access mode for write". Does anybody know what I forgot?
It should be the EXTERNAL clause instead of GLOBAL.

A LONG time ago we used the GLOBAL clause in the FD's of native .exes so that the .exe controlled the OPEN and CLOSE of files and called .dlls just read and wrote them. UNFORTUNATELY, that code was lost to the mists of time. Today we want to resurrect that functionality, but in Managed COBOL. I've put together an .exe that has FD LOG-FILE IS GLOBAL and does OPEN, WRITE, invokes a .dll, WRITEs again, and CLOSEs. The .dll (class) has FD LOG-FILE and does a write, no OPEN or CLOSE. Everything works in VS Debug mode until the WRITE in the .dll, which gets a 4/8 File Status and "148 Wrong open mode or access mode for write". Does anybody know what I forgot?
The EXTERNAL did the trick! Thanks for the clarification. As I said, the original code was gone but I remembered the functionality. While reading the documentation I didn't catch on that GLOBAL **ONLY** applies to all programs in a compilation, and our situation involves separate compilations.