-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCHEDULE-ADD.cbl
241 lines (228 loc) · 10.2 KB
/
SCHEDULE-ADD.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
*================================================================*
IDENTIFICATION DIVISION.
PROGRAM-ID SCHEDULE-ADD.
*================================================================*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
COPY MST-SELECTS.
*-----------------------------------------------------------------
DATA DIVISION.
*-----------------------------------------------------------------
FILE SECTION.
COPY MST-FD.
WORKING-STORAGE SECTION.
COPY WS-COMMON.
01 WS-REC.
03 WS-SCHED-ID.
05 WS-YEAR PIC 9(4) VALUE 2015.
05 FILLER PIC X.
05 WS-SEM PIC 99.
05 FILLER PIC X.
05 WS-CRN PIC 9(4).
03 FILLER PIC X.
03 WS-COURSE-ID.
05 WS-COURSE-DEPT PIC X(4).
05 FILLER PIC X.
04 WS-COURSE-NUM PIC X(4).
03 FILLER PIC X.
03 WS-TIMEDAY PIC X(20).
03 FILLER PIC X.
03 WS-BUILDING PIC X(11).
03 FILLER PIC X.
03 WS-INST-ID PIC 9(4).
03 FILLER PIC X.
03 WS-SEATS PIC 99.
*-----------------------------------------------------------------
SCREEN SECTION.
COPY SCR-COMMON.
01 SCRN-TITLE.
03 LINE 3 COL 30 VALUE 'ADD CLASS TO SCHEDULE'.
01 SCRN-DATA.
03 SCRN-YEAR.
05 LINE 6 COL 10 VALUE 'YEAR:'.
05 COL 25 PIC X(4) USING WS-YEAR
AUTO REQUIRED.
03 SCRN-SEM.
05 LINE 6 COL 35 VALUE 'SEM :'.
05 COL 45 PIC 99 USING WS-SEM
AUTO REQUIRED.
03 SCRN-CRN.
05 LINE 6 COL 50 VALUE 'CRN:'.
05 COL 55 PIC 9999 FROM WS-CRN.
03 SCRN-CRSE-DEPT.
05 LINE 8 COL 10 VALUE 'COURSE DEPT:'.
05 COL 25 PIC X(4) USING WS-COURSE-DEPT
AUTO REQUIRED.
03 SCRN-CRSE-ID.
05 LINE 8 COL 35 VALUE 'COURSE ID:'.
05 COL 45 PIC X(4) USING WS-COURSE-NUM
AUTO REQUIRED.
03 SCRN-CRS-NAME.
05 LINE 10 COL 10 VALUE 'COURSE:'.
05 COL 18 FROM CRSE-NAME.
03 SCRN-TIME.
05 LINE 12 COL 10 VALUE 'TIME / DAY:'.
05 COL 25 PIC X(20) USING WS-TIMEDAY
AUTO.
03 SCRN-BUILD.
05 LINE 14 COL 10 VALUE 'BUILDING:'.
05 COL 21 PIC X(12) USING WS-BUILDING
AUTO REQUIRED.
03 SCRN-INST.
05 LINE 16 COL 10 VALUE 'INSTRUCTOR ID:'.
05 COL 25 PIC 9999 USING WS-INST-ID
AUTO REQUIRED.
05 COL 30 VALUE 'INSTRUCTOR:'.
05 COL 42 PIC X(22) FROM INST-NAME.
03 SCRN-SEATS.
05 LINE 14 COL 35 VALUE 'MAX SEATS:'.
05 COL 45 PIC 99 USING WS-SEATS
AUTO REQUIRED.
*-----------------------------------------------------------------
PROCEDURE DIVISION.
000-MAIN.
OPEN I-O SCHED-MST.
OPEN I-O MST-CTRL-LIST.
MOVE 'Y' TO WS-ANOTHER.
PERFORM 100-ADD-TO-SCHED.
CLOSE SCHED-MST.
CLOSE MST-CTRL-LIST.
EXIT PROGRAM.
*-----------------------------------------------------------------
100-ADD-TO-SCHED.
PERFORM UNTIL ANOTHER
MOVE SPACES TO WS-SAVE, WS-REC, INST-REC
MOVE 2015 TO WS-YEAR
ACCEPT WS-DATE FROM DATE
ACCEPT WS-TIME FROM TIME
DISPLAY HEADER
DISPLAY SCRN-TITLE
DISPLAY SCRN-DATA
PERFORM 110-VAL-CRN
PERFORM 120-VAL-CRS
PERFORM 130-VAL-BLD
PERFORM 140-VAL-INS
PERFORM 150-SAVE
END-PERFORM.
*-----------------------------------------------------------------
110-VAL-CRN.
MOVE 'N' TO WS-VALIDATE.
PERFORM UNTIL VALIDATED
MOVE 0 TO WS-MST-REC-KEY
MOVE '01-SPRING 02-SUMMER-I 03-SUMMER-II 04-FALL' TO
WS-STATUS
DISPLAY SCRN-STATUS
ACCEPT SCRN-SEM
EVALUATE WS-SEM
WHEN '01' MOVE 3 TO WS-MST-REC-KEY
WHEN '05' MOVE 4 TO WS-MST-REC-KEY
WHEN '02' MOVE 7 TO WS-MST-REC-KEY
WHEN '04' MOVE 8 TO WS-MST-REC-KEY
END-EVALUATE
READ MST-CTRL-LIST
NOT INVALID KEY
MOVE MST-NEXT-CRN-CRN TO WS-STATUS
MOVE MST-NEXT-CRN-CRN TO WS-CRN
MOVE 'Y' TO WS-VALIDATE
DISPLAY SCRN-CRN
END-READ
END-PERFORM.
*-----------------------------------------------------------------
120-VAL-CRS.
OPEN INPUT CRSE-MASTER.
MOVE 'N' TO WS-VALIDATE.
PERFORM UNTIL VALIDATED
MOVE 'ENTER COURSE DEPT' TO WS-STATUS
DISPLAY SCRN-STATUS
ACCEPT SCRN-CRSE-DEPT
MOVE 'ENTER COURSE ID' TO WS-STATUS
DISPLAY SCRN-STATUS
ACCEPT SCRN-CRSE-ID
MOVE WS-COURSE-ID TO CRSE-ID
READ CRSE-MASTER
INVALID KEY
MOVE 'INVALID COURSE' TO WS-STATUS
DISPLAY SCRN-STATUS
NOT INVALID KEY
MOVE CRSE-NAME TO WS-STATUS
DISPLAY SCRN-STATUS
DISPLAY SCRN-CRS-NAME
MOVE 'Y' TO WS-VALIDATE
END-READ
END-PERFORM.
CLOSE CRSE-MASTER.
ACCEPT SCRN-TIME.
*-----------------------------------------------------------------
130-VAL-BLD.
OPEN INPUT BLD-MASTER.
MOVE 'N' TO WS-VALIDATE.
PERFORM UNTIL VALIDATED
MOVE 'ENTER ROOM ID' TO WS-STATUS
DISPLAY SCRN-STATUS
ACCEPT SCRN-BUILD
MOVE WS-BUILDING TO BLD-BUILDING-ROOM
READ BLD-MASTER
INVALID KEY
MOVE 'INVALID BUILDING' TO WS-STATUS
DISPLAY SCRN-STATUS
ACCEPT WS-RESP
NOT INVALID KEY
MOVE BLD-MAX-SEAT TO WS-SEATS
DISPLAY SCRN-SEATS
MOVE 'OVERRIDE SEATS?' TO WS-STATUS
DISPLAY SCRN-STATUS
ACCEPT SCRN-SEATS
MOVE 'Y' TO WS-VALIDATE
END-READ
END-PERFORM.
CLOSE BLD-MASTER.
*-----------------------------------------------------------------
140-VAL-INS.
OPEN INPUT INST-MASTER.
MOVE 'N' TO WS-VALIDATE.
MOVE 'ENTER INSTRUCTOR ID' TO WS-STATUS.
DISPLAY SCRN-STATUS.
PERFORM UNTIL VALIDATED
ACCEPT SCRN-INST
MOVE WS-INST-ID TO INST-ID
READ INST-MASTER
INVALID KEY
MOVE 'INVALID INSTRUCTOR' TO WS-STATUS
DISPLAY SCRN-STATUS
NOT INVALID KEY
MOVE INST-NAME TO WS-STATUS
DISPLAY SCRN-INST
MOVE 'Y' TO WS-VALIDATE
END-READ
END-PERFORM.
CLOSE INST-MASTER.
*-----------------------------------------------------------------
150-SAVE.
PERFORM UNTIL SAVE OR NOSAVE
DISPLAY SCRN-SAVE
ACCEPT SCRN-SAVE
IF SAVE THEN
MOVE WS-REC TO SCHED-REC
WRITE SCHED-REC
INVALID KEY
MOVE 'ERROR NOT SAVED' TO WS-STATUS
DISPLAY SCRN-STATUS
DISPLAY SCRN-ANOTHER
ACCEPT SCRN-ANOTHER
NOT INVALID KEY
MOVE SCHED-REC TO WS-STATUS
DISPLAY SCRN-SAVED
DISPLAY SCRN-STATUS
DISPLAY SCRN-ANOTHER
ACCEPT SCRN-ANOTHER
ADD 1 TO MST-NEXT-CRN-CRN
GIVING MST-NEXT-CRN-CRN
REWRITE MST-NEXT-CRNS
END-WRITE
ELSE
DISPLAY SCRN-CANCEL
DISPLAY SCRN-ANOTHER
ACCEPT SCRN-ANOTHER
END-IF
END-PERFORM.