Seznam článků

JDoodle - Online COBOL Compiler IDE ... ( Ctrl+C,  open this link in new panel, Ctrl+V, Submit )

identification division.
program-id. LS-FILE.    *> STDIN - file - screen
    *> *** the last line in STDIN must contain only *end 

environment division.
input-output section.
file-control.
    select FIL assign "LS-FILE" line sequential.
data division.
file section.
fd  FIL.
1   REC-F pic x(80).
working-storage section.
77  REC-I  pic x(80) value " ". 
77  F pic 9.
 88  INP-F value 0.
 88  END-F value 1.
 
procedure division.
    perform INP-PROC
    perform OUT-PROC
    stop run.
    
INP-REC.
    write REC-F from REC-I.
OUT-REC.
    move REC-F to REC-I
    display REC-I.
    
INP-PROC.
    open output FIL
    perform until REC-I = "*end"
        accept REC-I
        perform INP-REC end-perform
    close FIL.
OUT-PROC.
    open input FIL
    set INP-F to true
    perform until END-F
        read FIL
            end set END-F to true
            not end perform OUT-REC end-read end-perform
    close FIL.