CBL_DIR_SCAN_READ
The CBL_DIR_SCAN_READ library routine returns the next item in a list of files.
Note - The CBL_DIR_SCAN routines are supported for compatibility. If you’re writing new programs with isCOBOL, you may consider using C$LIST_DIRECTORY instead.
Syntax:
 CALL "CBL_DIR_SCAN_READ" USING dirHandle 
                                entry
                         GIVING returnCode
Parameters:
dirHandle
Handle
It must point to a valid handle returned by CBL_DIR_SCAN_START.
entry
Group Item
A group item defined as follows:
 
01 entry.
   03 attribute        pic x(4comp-n.
   03 date-stamp.
      05 year          pic x(4comp-n.
      05 month         pic x(2comp-n.
      05 day           pic x(2comp-n.
      05 hour          pic x(2comp-n.
      05 minute        pic x(2comp-n.
      05 second        pic x(2comp-n.
      05 millisec      pic x(2comp-n
      05 dst           pic x comp-n.
      05 size          pic x(8comp-n.
      05 name.
         07 max-len    pic x(2comp-n
         07 entry-name pic x(max-len).
Return code:
returnCode can be any numeric data item and provides additional information:
0
Operation successful.
1
An error occurred.
Examples:
Example - Open a directory, read all contents with CBL_DIR_SCAN_READ and then close it
working-storage section.
77  hDir                    handle.
 
01  pattern.
    03 pattern-length       pic x(2comp-n.
    03 pattern-content      pic x(128).
 
77  search-attribute        pic x(4comp-n.
77  search-flags            pic x(4comp-n.
 
01  dir-entry.
    03  dir-attribute       pic x(4comp-n.
    03  dir-date-stamp.
        05 dir-year         pic x(4comp-n.
        05 dir-month        pic x(2comp-n.
        05 dir-day          pic x(2comp-n.
        05 dir-hour         pic x(2comp-n.
        05 dir-minute       pic x(2comp-n.
        05 dir-second       pic x(2comp-n.
        05 dir-millisec     pic x(2comp-n.
        05 dir-dst          pic x(1comp-n.
        05 dir-size         pic x(8comp-n.
        05 dir-name.
           07 dir-name-len  pic x(2comp-n value 32.
           07 dir-entry-name pic x(32).
...
procedure division.
...
list-directory.
   initialize  pattern
   move "./*"  to pattern-content
   move 3      to pattern-length
   move 1      to search-attribute
   move 3      to search-flags
   call "cbl_dir_scan_start" using hDir
        pattern
        search-attribute
        search-flags 
   if return-code not = 0
      display message "Invalid directory"
      exit paragraph
   end-if
   perform until exit
      initialize dir-entry-name
      call "cbl_dir_scan_read" using hDir, dir-entry
      if return-code = 0    
         display dir-entry-name
      else
         exit perform
      end-if
   end-perform
   call "cbl_dir_scan_end" using hDir.