0

The program I have written is simple open a file, read it line by line and display selected lines. The file opens and the first read works.

I have a perform read-file until EOF.

but instead of doing another read it falls out the bottom and gives me this error:

libcob: C:/Users/saugu/Documents/Gix/Projects/FirstTry/bin/debug/x64/FIRSTTRY.cbsql:92: warning: implicit CLOSE of calin ('C:\Users\Public\Desktop\CalWork.txt')

snippit:

       evaluate true
       when cal-filestatus = "35"
            display "file not found"
       when cal-filestatus = "00"
            perform read-cal-file 
                until cal-eof
       when other
            display cal-filestatus,  msg
       end-evaluate.

read-cal-file.

       read calin
           at end
               set cal-eof to true
               close calin
           not at end
               perform check-line
       end-read.
       

   check-line.     
  
        if fdtstart = ldtstart
            display cal-record
        end-if
        if fdtend = ldtend
            display cal-record
        end-if
        if fsummary = lsummary
            display cal-record
        end-if.
        display cal-read-status.

(instead of going back it closes the file and ends the run.

I can get it to continue to read the file and display the info if I put 'go to read-cal-file' at the end of the check-line routine.

Thanks Jim

  • We'd need a full sample here, because we cannot see what the `read-cal-file` paragraph does, nor if the `check-line` paragraph may go on, including having a `goback`. You may want to have a look with a debugger or tracing (compile with `-ftraceall` and add a `SET ENVIRONMENT 'COB_SET_TRACE' TO '1'` in the program), to check the code flow. – Simon Sobisch Feb 08 '23 at 22:36
  • I made it an inline perform and all is working - but thanks for the comment. – James Sitko Feb 09 '23 at 01:58
  • sorry trying to recreate it but it is working right now - beats me why... – James Sitko Feb 09 '23 at 03:15

0 Answers0