skip to main content

Library Routines : I$IO

I$IO
The I$IO routine provides a low-level interface to indexed files allowing them to be managed without knowing their FD.
The routine is not affected by iscobol.file.prefix, iscobol.file.suffix and iscobol.file.index.strip_extension (boolean) configuration properties.
Syntax:
 CALL "I$IO" USING opCode 
            GIVING returnCode
Parameters:
Return code:
returnCode contains useful information such as file handles and record sizes or zero if an error occurs. Check the external variable F_ERRNO for additional information on the error.
Examples:
Example - Create an empty file with 1 key and 22 characters records lenght
      *> 01 record.
      *>  03 rec-key    pic 99.  *> This is the record key
      *>  03 rec-data   pic x(20).
working-storage section.
copy "isgui.def".
copy "isfilesys.def".
77  f                       handle .
77  file-io                 pic x(128).
77  key-io                  pic x(10).
procedure division.
   move "iss-file-io" to file-io
   move zero to block-multiple pre-allocation-amount 
   move 22 to max-rec-size
   move 22 to min-rec-size
   move 1 to num-keys
   move "1,0,2,0" to key-io
   inspect file-io replacing trailing spaces by low-value
   inspect key-io  replacing trailing spaces by low-value
   inspect logical-info  replacing trailing spaces by low-value
   set make-function to true                      
   call "i$io" using io-function, file-io, 0, physical-info, 
   if f_errno not = 0
      display message "I$IO Error: make : " f_errno 
   end-if
   goback.
Example - Open a file on I-O mode, get the record count, then close it
working-storage section.
copy "isgui.def".
copy "isfilesys.def".
77  f                       handle .
77  file-io                 pic x(128).
77  key-io                  pic x(10).
procedure division.
   move "iss-file-io" to file-io
   move 22 to max-rec-size
   move 22 to min-rec-size
   move  2 to num-keys
   set open-function to true
   move fio to open-mode    
   call "i$io" using io-function, file-io, 
   if return-code = 0
      display message "I$IO Error: open : " F_ERRNO 
   else
      move return-code to f
   end-if.
   set info-function to true
   set get-record-count to true
   call "I$IO" using io-function, f, info-mode, 
   set close-function to true
   call "i$io" using io-function  f
        giving returnCode
   if returnCode = 0
      display message "I$IO Error: close : " F_ERRNO 
   end-if.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left