-
Notifications
You must be signed in to change notification settings - Fork 0
/
READREL.cob
313 lines (257 loc) · 9.11 KB
/
READREL.cob
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
*=========================== READREL ============================*
* Authors: Brian D Pead
*
* License: MIT
*
* Description: Reads the relative file created by program BLDFILES
* in the specfied manner, and displays the records
* read.
*
* Date Version Description
* ---- ------- -----------
* 2020-02-08 1.0 First release
*================================================================*
IDENTIFICATION DIVISION.
*========================
PROGRAM-ID. READREL.
ENVIRONMENT DIVISION.
*=====================
CONFIGURATION SECTION.
*----------------------
SOURCE-COMPUTER.
IBM-Z15.
* IBM-Z15 DEBUGGING MODE.
INPUT-OUTPUT SECTION.
*---------------------
FILE-CONTROL.
SELECT NAMADDRL ASSIGN "Data\NAMEADDR.Rel.dat"
ORGANIZATION RELATIVE
ACCESS DYNAMIC
RELATIVE KEY W-RELATIVE-REC
FILE STATUS W-FILE-STATUS.
/
DATA DIVISION.
*==============
FILE SECTION.
*-------------
FD NAMADDRL.
01 NAMADDRL-REC. COPY NAMEADDR.
WORKING-STORAGE SECTION.
*------------------------
01 W-NAMADDRL-RECS PIC 9(09) COMP VALUE 0.
01 W-RETURN-CODE PIC S9(04) COMP.
01 W-DISP-NUM PIC ZZ,ZZ9.
01 W-ERROR-MSG PIC X(20) VALUE
'**** READREL error: '.
01 W-READ-METHOD PIC X(01).
88 W-READ-METHOD-RELATIVE VALUE 'R'.
88 W-READ-METHOD-SEQUENTIAL VALUE 'S'.
88 W-READ-METHOD-EXIT VALUE ' '.
88 W-READ-METHOD-VALID VALUE 'R'
'S'
' '.
01 W-RELATIVE-REC PIC 9(09).
88 W-RELATIVE-REC-EXIT VALUE 0.
01 FILLER PIC X(01).
88 W-INVALID-KEY VALUE 'Y'.
88 W-NOT-INVALID-KEY VALUE 'N'.
01 FILLER PIC X(01).
88 W-EOF VALUE 'Y'.
88 W-NOT-EOF VALUE 'N'.
01 W-FILE-STATUS PIC X(02).
88 W-FILE-STATUS-GOOD VALUE '00'.
01 W-COMPILED-DATE.
05 W-COMPILED-DATE-YYYY
PIC X(04).
05 W-COMPILED-DATE-MM PIC X(02).
05 W-COMPILED-DATE-DD PIC X(02).
05 W-COMPILED-TIME-HH PIC X(02).
05 W-COMPILED-TIME-MM PIC X(02).
05 W-COMPILED-TIME-SS PIC X(02).
05 FILLER PIC X(07).
/
PROCEDURE DIVISION.
*===================
MAIN.
*-----
PERFORM SUB-1000-START-UP THRU SUB-1000-EXIT
IF W-RETURN-CODE NOT = 0
GO TO MAIN-EXIT
END-IF
PERFORM SUB-9100-GET-READ-METHOD THRU SUB-9100-EXIT
PERFORM SUB-2000-PROCESS-READ-METHOD THRU SUB-2000-EXIT
UNTIL W-READ-METHOD-EXIT
OR W-RETURN-CODE NOT = 0
PERFORM SUB-3000-SHUT-DOWN THRU SUB-3000-EXIT
.
MAIN-EXIT.
STOP RUN.
/
SUB-1000-START-UP.
*------------------
MOVE 0 TO W-RETURN-CODE
MOVE FUNCTION WHEN-COMPILED
TO W-COMPILED-DATE
DISPLAY 'READREL compiled on '
W-COMPILED-DATE-YYYY '/'
W-COMPILED-DATE-MM '/'
W-COMPILED-DATE-DD ' at '
W-COMPILED-TIME-HH ':'
W-COMPILED-TIME-MM ':'
W-COMPILED-TIME-SS
OPEN INPUT NAMADDRL
IF NOT W-FILE-STATUS-GOOD
DISPLAY W-ERROR-MSG
'File status '
W-FILE-STATUS
' opening NAMADDRL'
MOVE 10 TO W-RETURN-CODE
END-IF
.
SUB-1000-EXIT.
EXIT.
/
SUB-2000-PROCESS-READ-METHOD.
*-----------------------------
IF W-READ-METHOD-RELATIVE
PERFORM SUB-9200-GET-RELATIVE-REC THRU SUB-9200-EXIT
PERFORM SUB-2100-READ-RELATIVE THRU SUB-2100-EXIT
UNTIL W-RELATIVE-REC-EXIT
ELSE
SET W-NOT-EOF TO TRUE
PERFORM SUB-2200-READ-SEQUENTIAL THRU SUB-2200-EXIT
UNTIL W-EOF
OR W-RETURN-CODE NOT = 0
END-IF
IF W-RETURN-CODE NOT = 0
GO TO SUB-2000-EXIT
END-IF
PERFORM SUB-9100-GET-READ-METHOD THRU SUB-9100-EXIT
.
SUB-2000-EXIT.
EXIT.
/
SUB-2100-READ-RELATIVE.
*-----------------------
PERFORM SUB-9300-READ-NAMADDRL-RELATIVE THRU SUB-9300-EXIT
IF W-NOT-INVALID-KEY
DISPLAY NAMADDRL-REC
END-IF
PERFORM SUB-9200-GET-RELATIVE-REC THRU SUB-9200-EXIT
.
SUB-2100-EXIT.
EXIT.
/
SUB-2200-READ-SEQUENTIAL.
*-------------------------
PERFORM SUB-9400-START-NAMADDRL THRU SUB-9400-EXIT
IF W-RETURN-CODE NOT = 0
GO TO SUB-2200-EXIT
END-IF
PERFORM SUB-9500-READ-NAMADDRL-SEQ THRU SUB-9500-EXIT
PERFORM UNTIL W-EOF
OR W-RETURN-CODE NOT = 0
DISPLAY NAMADDRL-REC
PERFORM SUB-9500-READ-NAMADDRL-SEQ THRU SUB-9500-EXIT
END-PERFORM
.
SUB-2200-EXIT.
EXIT.
/
SUB-3000-SHUT-DOWN.
*-------------------
CLOSE NAMADDRL
MOVE W-NAMADDRL-RECS TO W-DISP-NUM
DISPLAY 'NAMADDRL records read: '
W-DISP-NUM
DISPLAY 'READREL Completed'
.
SUB-3000-EXIT.
EXIT.
/
SUB-9100-GET-READ-METHOD.
*-------------------------
MOVE 'X' TO W-READ-METHOD
PERFORM UNTIL W-READ-METHOD-VALID
DISPLAY 'Enter R for relative reads, S for sequential, '
'space to exit: '
NO ADVANCING
ACCEPT W-READ-METHOD
MOVE FUNCTION UPPER-CASE(W-READ-METHOD)
TO W-READ-METHOD
END-PERFORM
.
SUB-9100-EXIT.
EXIT.
/
SUB-9200-GET-RELATIVE-REC.
*--------------------------
DISPLAY 'Enter relative record number (odd number since we '
'left space in file for the even ones) or space to '
'exit: '
NO ADVANCING
ACCEPT W-RELATIVE-REC
.
SUB-9200-EXIT.
EXIT.
/
SUB-9300-READ-NAMADDRL-RELATIVE.
*--------------------------------
READ NAMADDRL
INVALID KEY
SET W-INVALID-KEY
TO TRUE
DISPLAY 'Relative record not on file: '
W-RELATIVE-REC
GO TO SUB-9300-EXIT
END-READ
IF W-FILE-STATUS-GOOD
SET W-NOT-INVALID-KEY
TO TRUE
ADD 1 TO W-NAMADDRL-RECS
ELSE
DISPLAY W-ERROR-MSG
'File status '
W-FILE-STATUS
' reading NAMADDRL key'
MOVE 20 TO W-RETURN-CODE
END-IF
.
SUB-9300-EXIT.
EXIT.
/
SUB-9400-START-NAMADDRL.
*------------------------
START NAMADDRL
FIRST
END-START
IF NOT W-FILE-STATUS-GOOD
DISPLAY W-ERROR-MSG
'File status '
W-FILE-STATUS
' starting NAMADDRL'
MOVE 40 TO W-RETURN-CODE
END-IF
.
SUB-9400-EXIT.
EXIT.
/
SUB-9500-READ-NAMADDRL-SEQ.
*---------------------------
READ NAMADDRL NEXT
AT END
SET W-EOF TO TRUE
GO TO SUB-9500-EXIT
END-READ
IF W-FILE-STATUS-GOOD
ADD 1 TO W-NAMADDRL-RECS
ELSE
DISPLAY W-ERROR-MSG
'File status '
W-FILE-STATUS
' reading NAMADDRL next record'
MOVE 50 TO W-RETURN-CODE
END-IF
.
SUB-9500-EXIT.
EXIT.