skip to main content

Library Routines : CBL_CHECK_FILE_EXIST

CBL_CHECK_FILE_EXIST
The CBL_CHECK_FILE_EXIST library routine checks if a file exists. If the file exists, the routine returns information about the file.
Syntax:
 CALL "CBL_CHECK_FILE_EXIST" USING fileName 
Parameters:
If the name is a relative path and iscobol.file.prefix is set, then FILE-PREFIX paths are used to locate the file.
01 cblt-fileexist-buf.
  03 cblte-fe-filesize     pic x(8comp-x.
  03 cblte-fe-date.
    05 cblte-fe-day        pic x comp-x.
    05 cblte-fe-month      pic x comp-x.
    05 cblte-fe-year       pic x(2comp-x.
  03 cblte-fe-time.
    05 cblte-fe-hours      pic x comp-x.
    05 cblte-fe-minutes    pic x comp-x.
    05 cblte-fe-seconds    pic x comp-x.
    05 cblte-fe-hundredths pic x comp-x.
Return code:
returnCode can be any numeric data item and provides additional information:
Examples:
Example - Check if file exist and return information about it
working-storage section.
01 cbl-fileexist-buf.
   03 cblte-fe-filesize       pic x(8comp-x.
   03 cblte-fe-date.
      05 cblte-fe-day         pic x comp-x.
      05 cblte-fe-month       pic x comp-x.
      05 cblte-fe-year        pic x(2comp-x.
   03 cblte-fe-time.
      05 cblte-fe-hours       pic x comp-x.
      05 cblte-fe-minutes     pic x comp-x.
      05 cblte-fe-seconds     pic x comp-x.
      05 cblte-fe-hundredths  pic x comp-x.
procedure division.
   call "cbl_check_file_exist" 
                        using "c:\app1\config\settings.txt"
   if return-code = 0
      display message "File size : " cblte-fe-filesize
   else
      display message "File not found"
   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