Strana 1 z 4
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.
- Předchozí
- Další >>