Cevela about COBOL COBOL language - Home - Site Map - About Cevela - MX COBOL    <prev   next>
Sequential file handling - (demo c)
For more see - Formats in detail + Summary comment + How to use MX COBOL demos.

Writing into file and reading it
000000*..1....*....2....*....3....*....4....*....5....*....6....*....7..
      * Sequential file handling                                mx_c1.cb
      *
       file-control.
           select FIL assign NAM organization line sequential.
       file section.
       fd  FIL.
       1   REC pic x(80).
      *
       working-storage section.
       1   E pic 9 value 0.
        88  OUT-END value 1.
       1   NAM pic x(80) value "mx_c1.tmp".
       1   INP pic x(80) value ".".
        88  INP-END value " ".
       procedure division.
           inspect NAM replacing ending " " by #00#.
      *       obliged for the file-names in the MX COBOL
      *
           display "Data transfer from the keyboard into text-file:".
           display " ".
      *
           open output FIL.
           perform until (INP-END)
              display "data input / only Enter = end"
              accept INP
              if not (INP-END)
                 write REC from INP.
           close FIL.
      *
           display "Data transfer from the text-file on the screen:".
           display " ".
      *
           open input FIL.
           perform READ-FILE until (OUT-END).
           close FIL.
      *
           call "ICRUN" using "del mx_c1.tmp".
           stop run.
      *
       READ-FILE.
           read FIL
              end
                 move 1 to E.
           if not (OUT-END)
              display REC
              accept E.
    
MX COBOL + C compile listings - see here

MX COBOL - free compiler - © Vlastimil Cevela 2006

Date 2006-06-04 - Text Builder 0.65 - Time 06:30:58