xxx
JDoodle - Online COBOL Compiler IDE ...
( Ctrl+C, open this link in new panel, Ctrl+V, Submit )
identification division.
program-id. DATA-F.
*> 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 F pic 9.
88 INP-F value 0.
88 END-F value 1.
procedure division.
call "READ-STDIN"
open input FIL
set INP-F to true
perform until END-F
read FIL
end set END-F to true
not end display REC-F
end-read end-perform
close FIL
stop run.
program-id. READ-STDIN.
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 NUM-S pic 999.
77 REC-S pic x(80).
88 INP-S value space.
88 END-S value "*end".
procedure division.
initialize NUM-S REC-S.
open output FIL
perform until END-S
accept REC-S
if not END-S
write REC-F from REC-S
add 1 to NUM-S
end-if end-perform
close FIL
*> display "NUM-S=" NUM-S
exit program.
end program READ-STDIN.
end program DATA-F.
JDoodle - Online COBOL Compiler IDE ...
( Ctrl+C, open this link in new panel, Ctrl+V, Submit )
program-id. READ-STDIN.
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 NUM-S pic 999.
77 REC-S pic x(80).
88 INP-S value space.
88 END-S value "*end".
procedure division.
initialize NUM-S REC-S.
open output FIL
perform until END-S
accept REC-S
if not END-S
write REC-F from REC-S
add 1 to NUM-S
end-if end-perform
close FIL
*> display "NUM-S=" NUM-S
exit program.
end program READ-STDIN.
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.
xxx
identification division.
program-id. CALL-N.
procedure division.
display "main-prog"
call "N1"
display "return ok"
stop run.
program-id. N1.
procedure division.
display "N1"
exit program.
end program N1.
end program CALL-N.