kemaren baru saja saya share program C untuk baca file, kali ini saya akan memberikan program COBOL untuk baca file, berikut adalah listingnya :
IDENTIFICATION DIVISION.
PROGRAM-ID. SR.
AUTHOR. JUNIOR.
DATE-WRITTEN. 04-11-2012.
DATE-COMPILED. 04-11-2012.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DEPARTS ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS OUT.
DATA DIVISION.
FILE SECTION.
FD DEPARTS
LABEL RECORD IS STANDARD
VALUE OF FILE-ID IS 'AIRLINES.txt'
DATA RECORD IS DEPARTLIST.
01 DEPARTLIST.
02 A PIC X(3).
02 CODES PIC X(9).
02 B PIC X(3).
02 DESTIN PIC X(7).
02 C PIC X(3).
02 TIM PIC X(5).
WORKING-STORAGE SECTION.
77 OUT PIC XX.
01 DEPARTS-OUT.
02 A-OUT PIC X(3).
02 CODES-OUT PIC X(9).
02 B-OUT PIC X(3).
02 DESTIN-OUT PIC X(7).
02 C-OUT PIC X(3).
02 TIM-OUT PIC X(5).
01 GARIS PIC X(34) VALUE ALL '-'.
SCREEN SECTION.
01 HAPUS.
02 BLANK SCREEN.
01 JUDUL.
02 LINE 4 COLUMN 2 '| LIST OF DEPARTURES |'.
02 LINE 5 COLUMN 2 PIC X(34) USING GARIS.
02 LINE 6 COLUMN 2 '| PLANE-CODE DESTINATION TIME |'.
02 LINE 7 COLUMN 2 PIC X(34) USING GARIS.
PROCEDURE DIVISION.
BUKA-FILE.
OPEN INPUT DEPARTS.
MULAI.
DISPLAY HAPUS.
MOVE 8 TO LIN.
DISPLAY JUDUL.
BACA.
READ DEPARTS INTO DEPARTS-OUT
AT END GO TO SELESAI.
TAMPILKAN.
DISPLAY (LIN, 2) DEPARTS-OUT,
ADD 1 TO LIN.
GO TO BACA.
SELESAI.
DISPLAY (LIN, 2) GARIS.
CLOSE DEPARTS.
STOP RUN.
No comments:
Post a Comment