-
Notifications
You must be signed in to change notification settings - Fork 3
/
fileopen.cbl
executable file
·42 lines (42 loc) · 1.4 KB
/
fileopen.cbl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. FILE-READ-TEST-PROG.
000030 AUTHOR. SANDY DUNLOP.
000040*Based on: http://www.csis.ul.ie/COBOL/Course/SequentialFiles1.htm
000050
000060 ENVIRONMENT DIVISION.
000070 INPUT-OUTPUT SECTION.
000080 FILE-CONTROL.
000090 SELECT StudentFile ASSIGN TO "STUDENTS.DAT"
000100 ORGANIZATION IS LINE SEQUENTIAL.
000110
000120 DATA DIVISION.
000130 FILE SECTION.
000140 FD StudentFile.
000150 01 StudentRec.
000160 88 EndOfStudentFile VALUE HIGH-VALUES.
000170 02 StudentId PIC 9(7).
000180 02 StudentName.
000190 03 Surname PIC X(8).
000200 03 Initials PIC XX.
000210 02 DateOfBirth.
000220 03 YOBirth PIC 9(4).
000230 03 MOBirth PIC 9(2).
000240 03 DOBirth PIC 9(2).
000250 02 CourseCode PIC X(4).
000260 02 Gender PIC X.
000270
000280 PROCEDURE DIVISION.
000290 MAIN-PARAGRAPH.
000310 OPEN INPUT StudentFile.
000320 READ StudentFile
000330 AT END
000331 SET EndOfStudentFile TO TRUE
000340 END-READ
000350 PERFORM UNTIL EndOfStudentFile
000360 DISPLAY StudentId SPACE StudentName SPACE CourseCode
000370 READ StudentFile
000380 AT END SET EndOfStudentFile TO TRUE
000390 END-READ
000400 END-PERFORM
000410 CLOSE StudentFile
000420 STOP RUN.