Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Identification Division.
Program-ID. SAMPLE1.
Author. ADITYA -- Changes by WebRabbit.
Environment Division.
Input-Output Section.
File-Control.
Select DATAFILE
Assign to Disk
File Status is FILE-STATUS
Organization is Indexed
Access is Dynamic
Record Key is PERSON-KEY
.
Data Division.
File Section.
FD DATAFILE.
01 PERSON-RECORD.
05 PERSON-KEY Pic X(50).
05 PERSON-NAME.
10 PERSON-LAST-NAME Pic X(30).
10 PERSON-FIRST-NAME Pic X(20).
05 PERSON-PHONE Pic X(10).
05 PERSON-FAX Pic X(10).
05 PERSON-EMAIL Pic X(30).
Working-Storage Section.
01 FILE-STATUS.
88 ENTRY-NOT-FOUND Value "23".
88 DUPLICATE-ENTRY Value "22".
05 FILE-STATUS-1 Pic X(01).
88 FILE-OK Value "0".
88 FILE-AT-END Value "1".
05 FILE-STATUS-2 Pic X(01) Comp-X.
01 WORK-RECORD.
05 WORK-KEY Pic X(50).
05 WORK-NAME.
10 WORK-LAST-NAME Pic X(30).
10 WORK-FIRST-NAME Pic X(20).
05 WORK-PHONE Pic X(10).
05 WORK-FAX Pic X(10).
05 WORK-EMAIL Pic X(30).
01 OPTION Pic 9(01).
Procedure Division.
MAIN-ROUTINE.
Open I-O DATAFILE
If FILE-OK
Move Zero to OPTION
Display "Digital Organizer"
Perform Until OPTION = 3
Display "Select an Option"
Display "1 - New Entry"
Display "2 - View by Last Name"
Display "3 - Exit"
Accept OPTION
Evaluate OPTION
When 1
Perform ADD-A-NAME
When 2
Perform SEARCH-BY-LAST-NAME
When 3
Continue
When Other
Display "Invalid Option"
End-Evaluate
End-Perform
Close DATAFILE
End-If
Perform DISPLAY-ERROR
Stop Run
.
SEARCH-BY-LAST-NAME.
Move Space to WORK-LAST-NAME
Display "Enter Last Name - " with no Advancing
Accept WORK-LAST-NAME
If WORK-LAST-NAME not = Space
Move Function UPPER-CASE(WORK-LAST-NAME) to WORK-KEY
Move WORK-KEY to PERSON-KEY
Start DATAFILE Key = PERSON-KEY Size 30
If FILE-OK
Read DATAFILE Next Record
If FILE-OK
Move PERSON-RECORD to WORK-RECORD
Read DATAFILE Next Record
If FILE-AT-END
Move '00' to FILE-STATUS
Move Space to PERSON-KEY
End-If
If FILE-OK
If PERSON-KEY(1:30) = WORK-KEY(1:30)
Perform SEARCH-BY-FIRST-NAME
Else
Perform DISPLAY-ENTRY
End-If
End-If
End-If
End-If
Perform DISPLAY-ERROR
End-If
.
SEARCH-BY-FIRST-NAME.
Display "Multiple entries for " WORK-LAST-NAME
Move Space to WORK-FIRST-NAME
Display "Enter First Name - " with no Advancing
Accept WORK-FIRST-NAME
If WORK-FIRST-NAME not = Space
Move Function UPPER-CASE(WORK-NAME) to WORK-KEY
Move WORK-KEY to PERSON-KEY
Start DATAFILE Key = PERSON-KEY
If FILE-OK
Read DATAFILE Next Record
If FILE-OK
Move PERSON-RECORD to WORK-RECORD
Perform DISPLAY-ENTRY
End-If
End-If
End-If
.
DISPLAY-ERROR.
If FILE-STATUS-1 > "1"
Display " "
Evaluate True
When ENTRY-NOT-FOUND
Display "Not found."
When DUPLICATE-ENTRY
Display "Duplicate entry."
When Other
Display "File error - " with no advancing
If FILE-STATUS-1 = "9" or FILE-STATUS-2 < 48 or > 57
Display FILE-STATUS-2
Else
Display FILE-STATUS
End-If
End-Evaluate
Display " "
End-If
.
DISPLAY-ENTRY.
Display " "
Move Space to WORK-KEY
String WORK-FIRST-NAME Delimited by " " " " Delimited by Size WORK-LAST-NAME Delimited by " " into WORK-KEY
Display WORK-KEY
If WORK-PHONE not = Space
Display "Phone: " WORK-PHONE
End-If
If WORK-FAX not = Space
Display "Fax: " WORK-FAX
End-If
If WORK-EMAIL not = Space
Display "email: " WORK-EMAIL
End-If
Display " "
.
ADD-A-NAME.
Move Space to WORK-RECORD
Display "Enter First Name - " with no Advancing
Accept WORK-FIRST-NAME
If WORK-FIRST-NAME not = Space
Display "Enter Last Name - " with no Advancing
Accept WORK-LAST-NAME
If WORK-LAST-NAME not = Space
Move Function UPPER-CASE(WORK-NAME) to WORK-KEY
Move WORK-KEY to PERSON-KEY
Start DATAFILE Key = PERSON-KEY
If FILE-OK
Set DUPLICATE-ENTRY to True
Else
If ENTRY-NOT-FOUND
Display "Enter Phone - " with no Advancing
Accept WORK-PHONE
Display "Enter Fax - " with no Advancing
Accept WORK-FAX
Display "Enter email - " with no Advancing
Accept WORK-EMAIL
Write PERSON-RECORD from WORK-RECORD
End-If
End-If
Perform DISPLAY-ERROR
End-If
End-If
.