| ||||||||||||||
| ||||||||||||||
| ||||||||||||||
|
IDENTIFICATION DIVISION. PROGRAM-ID. LST002. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT F1 ASSIGN TO "C:\COBOL\LST002.CBL" STATUS FST ACCESS MODE IS SEQUENTIAL. DATA DIVISION. FILE SECTION. FD F1. 01 F1R PIC X(72). WORKING-STORAGE SECTION. 01 FST PIC X(02) VALUE SPACE. 01 CNT PIC 9(02) VALUE 0. PROCEDURE DIVISION. OPEN INPUT F1 PERFORM UNTIL FST NOT = "00" READ F1 END DISPLAY "<<< LST002 - ENDED >>>" NOT END DISPLAY F1R ADD 1 TO CNT IF CNT = 20 STOP "ABC" MOVE 0 TO CNT ELSE DISPLAY F1R END-IF END-READ END-PERFORM CLOSE F1 STOP RUN.
20までカウントアップして20になったら一旦止めてカウンタをゼロに戻す。まあこれは簡単ですよね。