Title: Does isCOBOL support C$REDIRECT?
C$REDIRECT is used to assign a different file I/O handler to a file.
There are several options to do the same in isCOBOL.

In version 2022R2 and later, you can write a hook program using this configuration to change the file handler class in the hook program.:
   iscobol.file.index.open_hook=Program Name 
If you are using a version before 2022R2, another option is to write an intermediary class, and assign that class as the file handler using "iscobol.file.index.".
There is an example of this in isCOBOL's Sample folder, %ISCOBOL%sampleextend-and-customizecustom-file-handlerlogging.
This program can be modified to handle your file operations at the interface level.
For example, if you want to call subprograms named BEFOREWRITE and AFTERWRITE before and after ever WRITE operation, you could edit the sample file CobLogging.cbl and change the "write" method to the following:
       IDENTIFICATION DIVISION.
       METHOD-ID. MY-WRITE AS "write".
       WORKING-STORAGE SECTION.
       77  RETURN-VALUE OBJECT REFERENCE JLONG.
       LINKAGE SECTION.
       77  THERECORD  OBJECT REFERENCE JBYTEARRAY.
       77  OFFS       OBJECT REFERENCE JINT.  
       77  RECSIZE    OBJECT REFERENCE JINT.     
       77  FLAGLOCK   OBJECT REFERENCE JBOOL.
       PROCEDURE DIVISION USING THERECORD,
                                OFFS,
                                RECSIZE,
                                FLAGLOCK
                      RETURNING RETURN-VALUE.
       MAIN.       

      *Trigger action - start
           CALL "BEFOREWRITE" USING THERECORD, OFFS, 
                RECSIZE, FLAGLOCK.
      *Trigger action - end

           SET RETURN-VALUE TO MY-ISAM:>write (THERECORD,
                                          OFFS,
                                          RECSIZE,
                                          FLAGLOCK).
      *Trigger action - start
           CALL "AFTERWRITE" USING THERECORD, OFFS, 
                RECSIZE, FLAGLOCK.
      *Trigger action - end

           GOBACK.
Authored by: Veryant Support on Fri, Mar 25th, 2011 at 7:00 PM
This question has been viewed 9190 times so far.
Online URL: http://support.veryant.com/support/phpkb/question.php?ID=167

Powered by PHPKB Knowledge Base Software