Vision filesystem - Obtaining the number of records in a file

0 Likes

Problem:

Is there any sample code that demonstrate how to obtain the number of records in a Vision file?

Resolution:

*Use the "filesys.def" copy file, which is included with the

*ACUCOBOL-GT product distribution.

Working-Storage Section.

01  the-filename         pic  x(15).

01  the-filename-full    pic  x(250).

01  num-recs-in-file     pic  9(9).

01  the-file-handle      usage is pointer.

copy "filesys.def".

Procedure Division.

      move "my_file.dat" to the-filename.

      move 500 to max-rec-size.

      move 500 to min-rec-size.

      move 3 to num-keys.

* Use runtime logic to find the full path of the filename

      call "c$fullname" using the-filename

           the-filename-full.

* Open the file

      move finput to open-mode.

      inspect the-filename-full replacing trailing spaces by

           null.

      call "i$io" using 1 the-filename-full, open-mode,

       logical-info.

      if return-code not equal null

* If the file opens successfully, call "I$IO" to get

* information on the file.

           move return-code to the-file-handle

           set info-function to true

           set get-record-count to true

           call "i$io" using io-function,

               the-file-handle, info-mode,

               record-count-info & nbsp;

           move number-of-records to num-recs-in-file

           display "Number of records is: " num-recs-in-file

           accept omitted

      else

           display "Can't get record information for: "

               the-filename

           accept omitted    

           exit paragraph

      end-if.

* Close the file

      call "i$io" using 2, the-file-handle.

Old KB# 2681
Comment List
Related
Recommended