Skip to Content

How do I write my own replacement for a C$ library routine?

Estimated Reading Time: 1 Minutes

Question:

Suppose that isCOBOL does not support a particular C$ library routine, such as C$GETPID, and I want to write my own so I won't need to change all of my existing calls. How do I do that?

Answer:

First, let us know which library isn't supported, so we can review it for inclusion in the next release.
In the meantime, if we don't have one already, you can write a program in COBOL to do the same thing.

For example, before 2020R2, CBL_READ_DIR wasn't supported.
But it was easily handled by writing a program called CBL_READ_DIR, with the parameters in the linkage section and a call to the duplicate library routine in isCOBOL, like this:

   PROGRAM-ID. CBL_READ_DIR.
   LINKAGE SECTION.
   01  LK-DIRNAME PIC X(256).   
   PROCEDURE DIVISION using LK-DIRNAME.
   MAIN.
      call "C$CHDIR" using LK-DIRNAME.
      goback.
With this program compiled and located in the same directory as the application, the original COBOL code worked without changes.

How do I write my own replacement for a C$ library routine?