Highlighted
Absent Member.
Absent Member.
840 views

C$REDIRECT HANDLER-FILE-HANDLE

[Migrated content. Thread originally posted on 14 July 2011]

Hi, i use the C$REDIRECT function in HANDLER-FUNCTION-REPLACE modality. In the handler i want to use the I$IO functions set.

In the handler, the OPEN-FUNC goes well and i move the handler of the open file to the HANDLER-FILE-HANDLE linkage item (i also tried without moving it in the linkage).

When i perform a READ on the file, my custom handler needs to perform the I$IO READ-FUNC but the HANDLER-FILE-HANDLE
points to an invalid location, not to the location of the just open file.

It follows a sample code:

THE I/O OPERATIONS:

open input myfile
move "OP" to myfile-key
read myfile key is myfile-key


THE HANDLER:
procedure division using HANDLER-INFO
                         HANDLER-FILE-INFO
                         HANDLER-STATE-INFO
                         HANDLER-RETURN-STATUS.
       inizio-programma.
           move 100 to werr-tbl-cod(w78err-inner-file-err).

           initialize werr-return-code.
           evaluate true
              when handler-op-open
                 perform open-file thru open-file-ex
              when handler-op-read
              when handler-op-read-lock
                 perform read-file thru read-file-ex
           end-evaluate.

       fine.                                 
           perform set-error-status thru set-error-status-ex.
           if werr-return-code > 0
              move "io" to handler-status-code
           end-if.
           exit program returning werr-return-code.

       open-file.
           evaluate true
              when handler-organization-indexed
                 set open-function to true
                 call "i$io" using io-function
                                   handler-file-name
                                   handler-open-mode
                                   handler-logical-params
                            giving handler-file-handle
                 if handler-file-handle = null
                    move handler-open-mode to w-str
                    string "open " w-str into w-except-params-arr(1)
                    move handler-file-name to w-except-params-arr(2)
                    move w78err-inner-file-err to werr-return-code
                 end-if
           end-evaluate.
       open-file-ex.
           exit.

       read-file.
           evaluate true
              when handler-organization-indexed
                 set read-function to true
                 call "i$io" using io-function
                                   handler-file-handle
                                   handler-record-area
                                   handler-key-number
                            giving werr-return-code
                 if werr-return-code = 0 | se non ha letto nessun byte
                    move "read "           to w-except-params-arr(1)
                    move handler-file-name to w-except-params-arr(2)
                    move w78err-inner-file-err to werr-return-code
                 else
                    initialize werr-return-code
                 end-if
           end-evaluate.
       read-file-ex.
           exit.

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: C$REDIRECT HANDLER-FILE-HANDLE

There is a C$REDIRECT example on http://supportline.microfocus.com/examplesandutilities/extend/SamplePrograms/GeneralProgTechniques.asp

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: C$REDIRECT HANDLER-FILE-HANDLE

The example does not fit my needs. I need to handle any file in handler, not a specific one, then i need to use the I$IO. The problem in using it is explained in my first question.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.