skip to main content

Library Routines : R$IO

R$IO
The R$IO routine provides a low-level interface to relative files allowing them to be managed without knowing their FD.
The routine is not affected by iscobol.file.prefix and iscobol.file.suffix configuration properties.
Syntax:
 CALL "R$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 a relative file, write and read records from it
 working-storage section.
 copy "isfilesys.def".
 77  f                       handle .
 77  file-io                 pic x(128).
 77  rec-buffer              pic x(22).
 01  rio-lparms.
     03 max-rec-sz           pic 999.
     03 filler               pic x value ",".
     03 min-rec-sz           pic 999.
 77  key-val                 pic 9(5value 0.
 procedure division.
 *> creates the file
 *> this is the FD
 *>  01 record.
 *>   03 r-key    pic 99.
 *>   03 r-data   pic x(20).
   display "Creating file..."
   move "c:\tmp\myrelfile" to file-io
   move 22 to max-rec-sz, min-rec-sz
   set r-make-function to true                      
   call "r$io" using rio-function, file-io, rio-lparms
   if return-code = 0
      display message "R$IO Error: make : " F_ERRNO 
   end-if           
   *> opening 
   display "Opening file..."
   set r-open-function to true
   move fio to open-mode
   move 22  to max-rec-size, min-rec-size
   call "r$io" using rio-function, file-io, open-mode 
   if return-code > 0
      move return-code to f
   else
      display message "R$IO Error: open : " F_ERRNO 
   end-if           
   *> record writing
   move 0 to key-val.
   display "Writing into file..."  
   set r-write-function to true
   perform 3 times
      add 1 to key-val
      move "00xxx" to rec-buffer     
      call "r$io" using rio-function, f, rec-buffer, 
      if return-code = 0
         display message "R$IO Error: write : " F_ERRNO 
   end-perform
   *> start
   display "Getting the first record..." 
   set r-start-function to true
   set f-equals       to true
   move 1             to key-val
   call "r$io" using rio-function, f, key-val, start-mode
   if return-code = 0
      display message "R$IO Error: start : " F_ERRNO 
   end-if
   *> read next
   display "Reading next record..."
   set r-next-function to true
   call "r$io" using rio-function, f, rec-buffer 
   if return-code = 0
      display message "R$IO Error: next : " F_ERRNO 
   end-if
   *> close
   display "Closing file..."
   set r-close-function to true
   call "r$io" using rio-function, f
   goback.

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