rp21

relativeFile

Sep 16th, 2015
488
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        IDENTIFICATION DIVISION.
  2.        PROGRAM-ID SEQ-REL.
  3.        ENVIRONMENT DIVISION.
  4.        INPUT-OUTPUT SECTION.
  5.        FILE-CONTROL.
  6.            SELECT F1 ASSIGN TO DISK
  7.            ORGANIZATION IS SEQUENTIAL
  8.            ACCESS MODE IS SEQUENTIAL.
  9.            SELECT F2 ASSIGN TO DISK
  10.            ORGANIZATION IS RELATIVE
  11.            ACCESS MODE IS RANDOM
  12.            RELATIVE KEY IS POS.
  13.        DATA DIVISION.
  14.        FILE SECTION.
  15.        FD F1
  16.           VALUE OF FILE-ID IS "SE.TXT"
  17.           LABEL RECORD ARE STANDARD.
  18.        01 REC1.
  19.           02 YEAR PIC 9(4).
  20.           02 POPU PIC X(6).
  21.        FD F2
  22.           VALUE OF FILE-ID IS "REL.TXT"
  23.           LABEL RECORD STANDARD.
  24.        01 REC2 PIC X(10).
  25.        WORKING-STORAGE SECTION.
  26.        01 POS PIC 99.
  27.        PROCEDURE DIVISION.
  28.        MAIN-PARA.
  29.            OPEN OUTPUT F1.
  30.            PERFORM INPUT-PARA 3 TIMES.
  31.            CLOSE F1.
  32.            OPEN INPUT F1.
  33.            OPEN OUTPUT F2.
  34.            GO TO READ-PARA.
  35.        INPUT-PARA.
  36.            DISPLAY "ENTER THE YEAR".
  37.            ACCEPT YEAR.
  38.            DISPLAY "ENTER THE POPULATION".
  39.            ACCEPT POPU.
  40.            WRITE REC1.
  41.        READ-PARA.
  42.            READ F1 AT END GO TO DISP-PARA.
  43.            COMPUTE POS = YEAR - 1900
  44.            MOVE REC1 TO REC2
  45.            WRITE REC2.
  46.            GO TO READ-PARA.
  47.        DISP-PARA.
  48.            CLOSE F1 F2.
  49.            OPEN INPUT F2.
  50.            DISPLAY "ENTER THE YEAR FOR POPULATION".
  51.            ACCEPT POS.
  52.            COMPUTE POS = POS - 1900.  
  53.        PARA-A.
  54.            READ F2 INVALID KEY GO TO PARA-B.
  55.            DISPLAY REC2.
  56.            GO TO EXIT-PARA.
  57.        PARA-B.
  58.            DISPLAY "RECORD NOT FOUND".
  59.            GO TO EXIT-PARA.  
  60.        EXIT-PARA.
  61.            CLOSE F2.
  62.            STOP RUN.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×