000100* Sample file reading program that outputs its source.
000200 IDENTIFICATION DIVISION.
000300 PROGRAM-ID. readfile.
000400
000500 ENVIRONMENT DIVISION.
000600    INPUT-OUTPUT SECTION.
000605       FILE-CONTROL.
000610       SELECT SRCCODE ASSIGN TO "readfile.cbl"
000615       ORGANIZATION IS LINE SEQUENTIAL.
000699
000700 DATA DIVISION.
000705    FILE SECTION.
000710    FD SRCCODE.
000715    01 SRCCODE-FILE.
000720       05 LINECODE PIC A(80).
000799
000800 WORKING-STORAGE SECTION.
000805    01 WS-SRCCODE.
000810       05 WS-LINECODE PIC A(80).
000815    01 WS-EOF PIC A(1).
000900    01 WS-NAME PIC A(6) VALUE IS "THERE".
001000
001100 PROCEDURE DIVISION.
001200    DISPLAY "Hello " WS-NAME "!".
001201    DISPLAY "Here's my source!".
001202    DISPLAY "***********************".
001205    OPEN INPUT SRCCODE.
001210       PERFORM UNTIL WS-EOF="Y"
001215       READ SRCCODE INTO WS-SRCCODE
001220          AT END MOVE "Y" TO WS-EOF
001225          NOT AT END DISPLAY WS-LINECODE
001230       END-READ
001235       END-PERFORM.
001240    CLOSE SRCCODE.
001241    DISPLAY "***********************".
001300 STOP RUN.
