-
Notifications
You must be signed in to change notification settings - Fork 0
/
phnadd02.cbl
94 lines (78 loc) · 2.7 KB
/
phnadd02.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
IDENTIFICATION DIVISION.
PROGRAM-ID. PHNADD02.
*----------------------------------------------------------
* This program creates a new daa file if necessary
* and adds records to the file from user entered
* data.
*----------------------------------------------------------
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROl.
SELECT OPTIONAL PHONE-FILE
* SELECT PHONE-FILE
ASSIGN TO "phone.dat"
* ASSIGN TO "phone"
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD PHONE-FILE
LABEL RECORDS ARE STANDARD.
01 PHONE-RECORD.
05 PHONE-LAST-NAME PIC X(20).
05 PHONE-FIRST-NAME PIC X(20).
05 PHONE-NUMBER PIC X(15).
05 PHONE-EXTENSION PIC X(5).
WORKING-STORAGE SECTION.
* Variables for SCREEN ENTRY
01 PROMPT-1 PIC X(9) VALUE "Last Name".
01 PROMPT-2 PIC X(10) VALUE "First Name".
01 PROMPT-3 PIC X(6) VALUE "Number".
01 PROMPT-4 PIC X(9) VALUE "Extension".
01 YES-NO PIC X.
01 ENTRY-OK PIC X.
PROCEDURE DIVISION.
MAIN-LOGIC SECTION.
PROGRAM-BEGIN.
PERFORM OPENING-PROCEDURE.
MOVE "Y" TO YES-NO.
PERFORM ADD-RECORDS
UNTIL YES-NO = "N"
PERFORM CLOSING-PROCEDURE.
PROGRAM-DONE.
STOP RUN.
* OPENING AND CLOSING
OPENING-PROCEDURE.
OPEN EXTEND PHONE-FILE.
CLOSING-PROCEDURE.
CLOSE PHONE-FILE.
ADD-RECORDS.
MOVE "N" TO ENTRY-OK.
PERFORM GET-FIELDS
UNTIL ENTRY-OK = "Y".
PERFORM ADD-THIS-RECORD.
PERFORM GO-AGAIN.
GET-FIELDS.
MOVE SPACE TO PHONE-RECORD.
DISPLAY PROMPT-1 " ? ".
ACCEPT PHONE-LAST-NAME.
DISPLAY PROMPT-2 " ? ".
ACCEPT PHONE-FIRST-NAME.
DISPLAY PROMPT-3 " ? ".
ACCEPT PHONE-NUMBER.
DISPLAY PROMPT-4 " ? ".
ACCEPT PHONE-EXTENSION.
PERFORM VALIDATE-FIELDS.
VALIDATE-FIELDS.
MOVE "Y" TO ENTRY-OK.
IF PHONE-LAST-NAME = SPACE
DISPLAY "LAST NAME MUST BE ENTERED"
MOVE "N" TO ENTRY-OK.
ADD-THIS-RECORD.
WRITE PHONE-RECORD.
GO-AGAIN.
DISPLAY "GO AGAIN?".
ACCEPT YES-NO.
IF YES-NO = "y"
MOVE "Y" TO YES-NO.
IF YES-NO NOT = "Y"
MOVE "N" TO YES-NO.