PROGRAM 14
IDENTIFICATION DIVISION. PROGRAM-ID. PROJ14. AUTHOR. ANTHONY F. ORTIZ. *********************************** * DEPARTMENT OF MOTOR VECHICLES * *********************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT LICENSE-FILE ASSIGN TO DISK "LICENSE.DAT" ORGANIZATION IS INDEXED RECORD KEY IS IN-LICENSE-PLATE ACCESS IS DYNAMIC. DATA DIVISION. FILE SECTION. FD LICENSE-FILE LABEL RECORD IS STANDARD. 01 IN-RECORD. 02 IN-LICENSE-PLATE PIC X(7). 02 IN-OWNER-NAME PIC X(20). 02 IN-MAKE-VEHICLE PIC X(8). 02 IN-STYLE-VEHICLE PIC X(8). 02 IN-COLOR-VEHICLE PIC X(8). WORKING-STORAGE SECTION. 01 PROGRAM-INDICATORS. 02 ERROR-FLAG PIC 9(1) VALUE ZERO. 02 LINE-CTR PIC 9(2) VALUE ZERO. 01 PROGRAM-VARIABLES. 02 INPUT-VARIABLES. 03 IN-CHOICE PIC X(1) VALUE SPACES. 03 IN-ANYCHAR PIC X(1) VALUE SPACES. 03 IN-ANS PIC X(1) VALUE SPACES. 03 IN-END-LICENSE PIC X(7) VALUE SPACES. 03 IN-END-IT PIC X(1) VALUE SPACES. 02 OUTPUT-VARIABLES. 03 OUT-LICENSE-PLATE PIC X(7) VALUE SPACES. 03 OUT-OWNER-NAME PIC X(20) VALUE SPACES. 03 OUT-MAKE-VEHICLE PIC X(8) VALUE SPACES. 03 OUT-STYLE-VEHICLE PIC X(8) VALUE SPACES. 03 OUT-COLOR-VEHICLE PIC X(8) VALUE SPACES. 01 PROGRAM-CONSTANTS. 02 INVALID-CHOICE PIC X(1) VALUE '7'. 02 ERROR-MESSAGE PIC X(38) VALUE 'ERROR, THIS RECORD IS NOT IN THE FILE.'. 02 ERROR-MESSAGE2 PIC X(38) VALUE 'ERROR, THIS RECORD ALREADY EXISTS. '. PROCEDURE DIVISION. MAIN-LINE. PERFORM OPEN-FILES. PERFORM GET-SELECTION UNTIL IN-CHOICE = '6'. PERFORM CLOSE-FILES. DISPLAY " " LINE 1 COL 1 WITH BLANK SCREEN. STOP RUN. OPEN-FILES. OPEN I-O LICENSE-FILE. GET-SELECTION. PERFORM MAKE-SURE-IT-PAUSES-FOR-INPUT. PERFORM PRINT-MENU UNTIL IN-CHOICE = '1' OR IN-CHOICE = '2' OR IN-CHOICE = '3' OR IN-CHOICE = '4' OR IN-CHOICE = '5' OR IN-CHOICE = '6'. IF IN-CHOICE = '1' PERFORM INITIALIZE-IN-LICENSE-PLATE PERFORM INQUIRE-SINGLE-LICENSE-PLATE THRU END-INQUIRE UNTIL IN-LICENSE-PLATE = SPACES ELSE IF IN-CHOICE = '2' PERFORM INITIALIZE-IN-LICENSE-PLATE PERFORM INQUIRE-RANGE-LICENSE-PLATE THRU END-RANGE UNTIL IN-LICENSE-PLATE = SPACES ELSE IF IN-CHOICE = '3' PERFORM INITIALIZE-IN-LICENSE-PLATE PERFORM ADD-LICENSE-PLATE THRU END-ADD UNTIL IN-LICENSE-PLATE = SPACES ELSE IF IN-CHOICE = '4' PERFORM INITIALIZE-IN-LICENSE-PLATE PERFORM CHANGE-LICENSE-PLATE THRU END-RANGE UNTIL IN-LICENSE-PLATE = SPACES ELSE IF IN-CHOICE = '5' PERFORM INITIALIZE-IN-LICENSE-PLATE PERFORM DELETE-LICENSE-PLATE THRU END-DEL UNTIL IN-LICENSE-PLATE = SPACES. MAKE-SURE-IT-PAUSES-FOR-INPUT. MOVE INVALID-CHOICE TO IN-CHOICE. PRINT-MENU. DISPLAY "DEPARTMENT OF MOTOR VEHICLES" LINE 1 COL 1 WITH BLANK SCREEN. DISPLAY "1. INQUIRE SINGLE LICENSE PLATE DATA." LINE 3 COL 5. DISPLAY "2. INQUIRE RANGE OF LICENSE PLATE DATA." LINE 4 COL 5. DISPLAY "3. ADD LICENSE PLATE DATA." LINE 5 COL 5. DISPLAY "4. CHANGE LICENSE PLATE DATA." LINE 6 COL 5. DISPLAY "5. DELETE LICENSE PLATE DATA." LINE 7 COL 5. DISPLAY "6. TERMINATE THE PROGRAM." LINE 8 COL 5. DISPLAY "PRESS ENTER KEY TO CONTINUE. " LINE 10 COL 1. ACCEPT IN-CHOICE LINE 10 COL 30. IF IN-CHOICE < '1' OR IN-CHOICE > '6' DISPLAY " " LINE 10 COL 30 WITH BEEP. INITIALIZE-IN-LICENSE-PLATE. MOVE HIGH-VALUE TO IN-LICENSE-PLATE. INQUIRE-SINGLE-LICENSE-PLATE. DISPLAY "ENTER A 7 CHARACTER LICENSE PLATE. " LINE 1 COL 1 WITH BLANK SCREEN. DISPLAY "PRESS ENTER KEY (ONLY) TO CONTINUE." LINE 3 COL 1. PERFORM INITIALIZE-IN-RECORD. ACCEPT IN-LICENSE-PLATE LINE 1 COL 36. IF IN-LICENSE-PLATE = SPACES GO TO END-INQUIRE. PERFORM READ-FILE. IF ERROR-FLAG = 1 PERFORM MOVE-IN-OUT PERFORM DISPLAY-RECORD PERFORM PRESS-ENTER-KEY ELSE PERFORM PRINT-ERROR-MESSAGE PERFORM PRESS-ENTER-KEY. END-INQUIRE. EXIT. INITIALIZE-IN-RECORD. MOVE SPACES TO IN-RECORD. READ-FILE. PERFORM INITIALIZE-ERROR-FLAG. READ LICENSE-FILE INVALID MOVE 2 TO ERROR-FLAG. INITIALIZE-ERROR-FLAG. MOVE 1 TO ERROR-FLAG. MOVE-IN-OUT. MOVE IN-LICENSE-PLATE TO OUT-LICENSE-PLATE. MOVE IN-OWNER-NAME TO OUT-OWNER-NAME. MOVE IN-MAKE-VEHICLE TO OUT-MAKE-VEHICLE. MOVE IN-COLOR-VEHICLE TO OUT-COLOR-VEHICLE. MOVE IN-STYLE-VEHICLE TO OUT-STYLE-VEHICLE. DISPLAY-RECORD. DISPLAY "LICENSE PLATE: " LINE 1 COL 1 WITH BLANK SCREEN. DISPLAY "OWNER'S NAME: " LINE 3 COL 1. DISPLAY "MAKE OF VEHICLE: " LINE 5 COL 1. DISPLAY "COLOR OF VEHICLE: " LINE 7 COL 1. DISPLAY "STYLE OF VEHICLE: " LINE 9 COL 1. DISPLAY OUT-LICENSE-PLATE LINE 1 COL 19. DISPLAY OUT-OWNER-NAME LINE 3 COL 19. DISPLAY OUT-MAKE-VEHICLE LINE 5 COL 19. DISPLAY OUT-COLOR-VEHICLE LINE 7 COL 19. DISPLAY OUT-STYLE-VEHICLE LINE 9 COL 19. PRESS-ENTER-KEY. DISPLAY "PRESS ENTER KEY TO CONTINUE ..... " LINE 13 COL 1. ACCEPT IN-ANYCHAR. PRINT-ERROR-MESSAGE. DISPLAY ERROR-MESSAGE LINE 1 COL 1 WITH BLANK SCREEN. INQUIRE-RANGE-LICENSE-PLATE. DISPLAY "KEY IN STARTING LICENSE:" LINE 1 COL 1 WITH BLANK SCREEN. DISPLAY "OR" LINE 3 COL 1. DISPLAY "KEY-IN 'ALL' FOR ENTIRE FILE." LINE 5 COL 1. DISPLAY "OR" LINE 7 COL 1. DISPLAY "PRESS ENTER (ONLY) TO RETURN TO MAIN MENU. " LINE 9 COL 1. PERFORM INITIALIZE-IN-LICENSE-PLATE. ACCEPT IN-LICENSE-PLATE LINE 1 COL 26. IF IN-LICENSE-PLATE = 'ALL ' MOVE LOW-VALUE TO IN-LICENSE-PLATE MOVE HIGH-VALUE TO IN-END-LICENSE GO TO START-IT. IF IN-LICENSE-PLATE = SPACES MOVE 'Y' TO IN-END-IT GO TO END-RANGE. DISPLAY "KEY-IN ENDING LICENSE: " LINE 1 COL 34. PERFORM INITIALIZE-END-LICENSE. ACCEPT IN-END-LICENSE LINE 1 COL 57. IF IN-END-LICENSE < IN-LICENSE-PLATE PERFORM HIGH-LOW-ERROR GO TO INQUIRE-RANGE-LICENSE-PLATE. START-IT. START LICENSE-FILE KEY IS GREATER THAN OR EQUAL TO IN-LICENSE-PLATE INVALID PERFORM NOT-THERE GO TO INQUIRE-RANGE-LICENSE-PLATE. DISPLAY "NUMBER NAME STYLE COLOR" LINE 1 COL 1 WITH BLANK SCREEN. DISPLAY " ". PERFORM INITIALIZE-LINE-CTR. READ-AGAIN. READ LICENSE-FILE NEXT RECORD AT END PERFORM END-SHOW-TIME GO TO END-RANGE. IF IN-LICENSE-PLATE > IN-END-LICENSE PERFORM END-SHOW-TIME GO TO END-RANGE. ADD 1 TO LINE-CTR. IF LINE-CTR = 20 PERFORM SCREEN-FULL IF IN-END-IT = 'Y' GO TO END-RANGE. DISPLAY IN-LICENSE-PLATE " " IN-OWNER-NAME " " IN-STYLE-VEHICLE " " IN-COLOR-VEHICLE. GO TO READ-AGAIN. END-RANGE. EXIT. SCREEN-FULL. DISPLAY "PRESS ENTER KEY TO CONTINUE OR KEY E TO" LINE 23 COL 1. DISPLAY " TERMINATE." LINE 23 COL 39. PERFORM INITIALIZE-IN-ANS. ACCEPT IN-ANS LINE 23 COL 51. IF IN-ANS = 'E' MOVE 'Y' TO IN-END-IT. HIGH-LOW-ERROR. DISPLAY "ENDING LICENSE PLATE MUST NOT BE BEFORE START" LINE 1 COL 1 WITH BLANK SCREEN. PERFORM PRESS-ENTER-KEY. NOT-THERE. DISPLAY "CANNOT DO, NOTHING IN FILE FOR THAT RANGE " LINE 1 COL 1 WITH BLANK SCREEN. PERFORM PRESS-ENTER-KEY. END-SHOW-TIME. PERFORM PRESS-ENTER-KEY. INITIALIZE-END-LICENSE. MOVE SPACES TO IN-END-LICENSE. INITIALIZE-LINE-CTR. MOVE 0 TO LINE-CTR. ADD-LICENSE-PLATE. DISPLAY "ENTER NEW LICENSE PLATE NUMBER." LINE 1 COL 1 WITH BLANK SCREEN. DISPLAY " PRESS ENTER KEY (ONLY) TO CONTINUE. " LINE 1 COL 32. PERFORM INITIALIZE-IN-RECORD. ACCEPT IN-LICENSE-PLATE LINE 1 COL 70. IF IN-LICENSE-PLATE = SPACES GO TO END-ADD. PERFORM READ-FILE. IF ERROR-FLAG = 1 PERFORM MOVE-IN-OUT PERFORM DISPLAY-RECORD PERFORM PRINT-ERROR-MESSAGE2 PERFORM PRESS-ENTER-KEY GO TO END-ADD ELSE PERFORM INPUT-RECORD IF IN-ANS = 'Y' OR 'y' PERFORM WRITE-RECORD. END-ADD. EXIT. INPUT-RECORD. DISPLAY "ENTER OWNER'S NAME. " LINE 3 COL 1. DISPLAY "ENTER MAKE OF VEHICLE. " LINE 5 COL 1. DISPLAY "ENTER COLOR OF VEHICLE. " LINE 7 COL 1. DISPLAY "ENTER STYLE OF VEHICLE. " LINE 9 COL 1. DISPLAY "TYPE 'Y' TO ADD/CHANGE RECORD." LINE 11 COL 1. DISPLAY " TYPE 'N' NOT TO ADD/CHANGE RECORD. " ACCEPT IN-OWNER-NAME LINE 3 COL 25 WITH UPDATE. ACCEPT IN-MAKE-VEHICLE LINE 5 COL 25 WITH UPDATE. ACCEPT IN-COLOR-VEHICLE LINE 7 COL 25 WITH UPDATE. ACCEPT IN-STYLE-VEHICLE LINE 9 COL 25 WITH UPDATE. PERFORM INITIALIZE-IN-ANS. PERFORM INPUT-ANS UNTIL IN-ANS = 'Y' OR 'y' OR 'N' OR 'n'. PRINT-ERROR-MESSAGE2. DISPLAY ERROR-MESSAGE2 LINE 11 COL 1. INITIALIZE-IN-ANS. MOVE ' ' TO IN-ANS. INPUT-ANS. ACCEPT IN-ANS LINE 11 COL 68. IF IN-ANS IS NOT EQUAL TO 'Y' AND IN-ANS IS NOT EQUAL TO 'y' AND IN-ANS IS NOT EQUAL TO 'N' AND IN-ANS IS NOT EQUAL TO 'n' DISPLAY " " LINE 11 COL 68 WITH BEEP. WRITE-RECORD. WRITE IN-RECORD. CHANGE-LICENSE-PLATE. DISPLAY "ENTER LICENSE PLATE IN ORDER TO CHANGE IT. " LINE 1 COL 1 WITH BLANK SCREEN. PERFORM INITIALIZE-IN-RECORD. ACCEPT IN-LICENSE-PLATE LINE 1 COL 44. IF IN-LICENSE-PLATE = SPACES GO TO END-CHANGE. PERFORM READ-FILE. IF ERROR-FLAG = 1 PERFORM INPUT-RECORD IF IN-ANS = 'Y' OR IN-ANS = 'y' PERFORM REWRITE-RECORD ELSE NEXT SENTENCE ELSE PERFORM PRINT-ERROR-MESSAGE PERFORM PRESS-ENTER-KEY. END-CHANGE. EXIT. REWRITE-RECORD. REWRITE IN-RECORD. DELETE-LICENSE-PLATE. DISPLAY "ENTER LICENSE PLATE IN ORDER TO DELETE IT. " LINE 1 COL 1 WITH BLANK SCREEN. PERFORM INITIALIZE-IN-RECORD. ACCEPT IN-LICENSE-PLATE LINE 1 COL 44. IF IN-LICENSE-PLATE = SPACES GO TO END-DEL. PERFORM READ-FILE. IF ERROR-FLAG = 1 PERFORM MOVE-IN-OUT PERFORM DISPLAY-RECORD DISPLAY "TYPE 'Y' TO DELETE FILE." LINE 11 COL 1 DISPLAY " TYPE 'N' TO NOT DELETE FILE. " LINE 11 COL 24 PERFORM INITIALIZE-IN-ANS PERFORM INPUT-ANS UNTIL IN-ANS = 'Y' OR IN-ANS = 'y' OR IN-ANS = 'N' OR IN-ANS = 'n' IF IN-ANS = 'Y' OR IN-ANS = 'y' DELETE LICENSE-FILE ELSE NEXT SENTENCE ELSE PERFORM PRINT-ERROR-MESSAGE PERFORM PRESS-ENTER-KEY. END-DEL. EXIT. CLOSE-FILES. CLOSE LICENSE-FILE. * DATA FILE: LICENSE.DAT, LICENSE.IDX (NOT TEXT FILES) * * OUTFILE: PROG14.OUT * DEPARTMENT OF MOTOR VEHICLES 1. INQUIRE SINGLE LICENSE PLATE DATA. 2. INQUIRE RANGE OF LICENSE PLATE DATA. 3. ADD LICENSE PLATE DATA. 4. CHANGE LICENSE PLATE DATA. 5. DELETE LICENSE PLATE DATA. 6. TERMINATE THE PROGRAM. PRESS ENTER KEY TO CONTINUE. 6
BACK TO CIS165 PAGE.