       IDENTIFICATION DIVISION.
       PROGRAM-ID.   RMCRL1.
      *                         VER.  2.0
      *              (RELATIVE FILE CONVERSION PROGRAM)
      *    DATE REVISED   22 DEC 83
      *
      *    ---   ---   Please take note   ---   ---
      *        This is just a simple program that you must
      *        edit, compile and run.  The edits involve
      *        the input filename, the output filename
      *        and the record size of the old file.
      *        The operation of the program is to simply
      *        read records from the old file, strip off two
      *        leading bytes (a byte count) and write the
      *        bare record to the output file.
      *     ---  ---  ---  ---  ---  ---  ---  ---  ---  ---  ---
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.   RMC.
       OBJECT-COMPUTER.   RMC.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
      *      CHANGE "OUTNAME.EXT" TO BE THE FILE NAME OF THE
      *      OUTPUT FILE.
       SELECT OUT-FILE ASSIGN TO RANDOM "OUTNAME.EXT"
           ORGANIZATION IS RELATIVE.
      *      CHANGE "INNAME.EXT" TO BE THE FILE NAME OF THE
      *      OLD FILE TO BE CONVERTED.
       SELECT IN-FILE ASSIGN TO RANDOM "INNAME.EXT"
           ORGANIZATION IS BINARY SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  OUT-FILE.
       01  OUT-RECORD.
      *      SET THE SIZE OF DATA-OUT TO BE THE ACTUAL RECORD SIZE
      *      THAT THE OLD FILE WAS DECLARED TO BE
           03  DATA-OUT    PIC  X(300).
       FD  IN-FILE.
       01  IN-RECORD.
      *      THIS FILLER IS A 2-BYTE BYTE COUNT AT THE BEGINNING
      *      OF EACH OLD RECORD.  IT IS NOT NEEDED IN THE NEW
      *      FORMATS.
           03  FILLER      PIC  X(2).
      *      SET THE SIZE OF DATA-IN TO BE THE ACTUAL RECORD SIZE
      *      THAT THE OLD FILE WAS DECLARED TO BE
           03  DATA-IN     PIC  X(300).
       WORKING-STORAGE SECTION.
       77  NUMBER-OF-RECORDS   PIC  9999  VALUE IS ZERO.
       77  EOF-IND             PIC  X     VALUE IS "N".
       PROCEDURE DIVISION.
       MAIN SECTION.
       START-UP.
           DISPLAY  "RM/COBOL Relative file conversion program"
              LINE 2 POSITION 15 ERASE.
           DISPLAY  " ".
           DISPLAY  " ".
           DISPLAY  "     You must edit and compile this program before".
           DISPLAY  "         you run it.  Have you done this? (Y/N) ".
           ACCEPT  EOF-IND UPDATE POSITION 0 TAB.
           IF EOF-IND IS NOT EQUAL TO "Y" STOP RUN.
           MOVE "N" TO EOF-IND.
           OPEN OUTPUT  OUT-FILE.
           OPEN INPUT   IN-FILE.
           DISPLAY  " ".
           DISPLAY  " ".
           DISPLAY  "Files opened ok."
           DISPLAY  "Number of records written " LINE 10.
       LOOP.
           PERFORM READ-A-RECORD.
           IF EOF-IND = "Y" GO TO DONE.
           PERFORM WRITE-A-RECORD.
           GO TO LOOP.
       READ-A-RECORD.
           READ IN-FILE RECORD INTO IN-RECORD
           AT END MOVE "Y" TO EOF-IND.
       WRITE-A-RECORD.
           MOVE DATA-IN TO DATA-OUT.
           WRITE OUT-RECORD.
           ADD 1 TO NUMBER-OF-RECORDS.
           DISPLAY NUMBER-OF-RECORDS LINE 10 POSITION 28.
       DONE.
           CLOSE OUT-FILE.
           CLOSE IN-FILE.
           DISPLAY  "Files closed ok.  Conversion successful."
           STOP RUN.
       END PROGRAM.
