       IDENTIFICATION DIVISION.
       PROGRAM-ID.  RMCFGN.
      *                 Ver. 2.0B
      *            (FILE-CONTROL AND FILE SECTION SOURCE CODE
      *            (GENERATOR FOR ISAM DATA CONVERSION PROGRAM
      *     Date Revised    12 July 1984
      *     Prev Revised    19 Dec 1983
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.  RMCOBOL.
       OBJECT-COMPUTER.  RMCOBOL.
      *
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT SEQ-COPYFILE-1 ASSIGN TO RANDOM "COPYFC.CNV"
           ORGANIZATION IS LINE SEQUENTIAL.
       SELECT SEQ-COPYFILE-2 ASSIGN TO RANDOM "COPYFS.CNV"
           ORGANIZATION IS LINE SEQUENTIAL.
       SELECT ISM-FILE ASSIGN TO RANDOM FILE-NAME
           ORGANIZATION IS BINARY SEQUENTIAL.
      *
       DATA DIVISION.
       FILE SECTION.
       FD  SEQ-COPYFILE-1.
       01  SEQ-REC-1.
           03  FIRST-40-1                    PIC X(40).
           03  SECOND-40-1                   PIC X(40).
       FD  SEQ-COPYFILE-2.
       01  SEQ-REC-2.
           03  FIRST-40-2.
               05  FIRST-24-2                PIC X(24).
               05  ALT-NUM                   PIC 99.
               05  FILLER                    PIC X(14).
           03  SECOND-40-2.
               05  PIC-1                     PIC X(6).
               05  PIC-LENGTH                PIC 9(4).
               05  PIC-2                     PIC X(30).
       FD  ISM-FILE.
       01  ISM-REC                           PIC X(256).
      /
       WORKING-STORAGE SECTION.
      *
      *   (initial variables)
      *
       77  RETURN-KEY                        PIC X.
       77  CORRECTION-KEY                    PIC X.
       77  COUNTER                           PIC 99.
       77  DUMMY                             PIC 99.
       77  HEADER-FLG                        PIC 9     VALUE 1.
           88  HEADER-NOT-OK        VALUE 0.
       77  FLIPPED-FLG                        PIC 9.
           88  FLIPPED-BYTES        VALUE 1.
       77  I                                 PIC 9     VALUE 0.
       77  J                                 PIC 9     VALUE 0.
       77  K                                 PIC 99    VALUE 3.
       77  L                                 PIC 99    VALUE 3.
       77  M                                 PIC 99    VALUE 0.
       77  N                                 PIC 99    VALUE 0.
       77  EXTRA                             PIC 9(4).
       77  FILLER-LINE                       PIC X(25)
               VALUE "               05  FILLER".
       77  ALTN-LINE                         PIC X(24)
               VALUE "           03  ALTN-REC-".
      *
      *   (accept/display storage)
      *
       77  FILE-NAME                         PIC X(19).
       77  FILE-SIZE                         PIC 9(6).
       77  DATA-REC-SIZE                     PIC 9(4).
       77  PRI-SIZE                          PIC 999.
       77  PRI-OFFSET                        PIC 9(4).
       77  ALT-KEYS                          PIC 99.
       77  ALT-NUMBER                        PIC 99.
       01  TABLE-1.
           02  ALT-KEY-TABLE OCCURS 14 TIMES.
               03  ALT-SIZE                  PIC 999.   
               03  ALT-OFFSET                PIC 9(4).
               03  DUP-NUM                   PIC X.
      *
      *    (calculation variables)
      *
       77  PRI-TOTAL                         PIC 9(4).
       77  ALT-TOTAL                         PIC 9(4).
      /
      *
      *    (header storage)
      *
       01  HEADER-FORMAT.
           02  FIRST-AU                                USAGE COMP-1.
               03  HEADER-CODE-WORD          PIC S9(5).
               03  AUS-PER-HEADER            PIC 9.
               03  AUS-PER-DATA-REC          PIC 99.
               03  FREE-NODE-LIST-HEAD-1     PIC 9.
               03  FREE-NODE-LIST-HEAD-2     PIC 99.
               03  FREE-NODE-NUM             PIC 9(5).
               03  FREE-REC-LIST-HEAD-1      PIC 9.
               03  FREE-REC-LIST-HEAD-2      PIC 9.
               03  FREE-REC-NUM              PIC 9.
               03  FREE-DUP-LIST-HEAD-1      PIC 9(5).
               03  FREE-DUP-LIST-HEAD-2      PIC 9(5).
               03  FREE-DUP-NUM              PIC 9(5).
               03  NEXT-FREE-AU-1            PIC 9(5).
               03  NEXT-FREE-AU-2            PIC 9(5).    
               03  FLAG-WORD                 PIC 9.
               03  NUMBER-OF-KEYS            PIC 99.
           02  PRI-KEY-BLOCK.
               03  PRI-KEY-SIZE              PIC 999   USAGE COMP-1.
               03  PRI-KEY-OFFSET            PIC 9(4)  USAGE COMP-1.
               03  FILLER                    PIC X(10).
           02  TABLE-2.
               03  ALT-KEY-BLOCK OCCURS 14 TIMES.        
                   04  ALT-KEY-SIZE          PIC 999   USAGE COMP-1.
                   04  ALT-KEY-OFFSET        PIC 9(4)  USAGE COMP-1.
                   04  FILLER                PIC X(10).
           02  FILLER                        PIC X(14).
      /
       01  HEADER-BYTES                      REDEFINES HEADER-FORMAT.
           02  FIRST-BYTES.
               03  HCL                       PIC X.
               03  HCH                       PIC X.
               03  FILLER                    PIC X(28).
               03  NKL                       PIC X.
               03  NKH                       PIC X.
           02  KEY-BYTES                     OCCURS 15 TIMES.
               03  KSL                       PIC X.
               03  KSH                       PIC X.
               03  KOL                       PIC X.
               03  KOH                       PIC X.
               03  FILLER                    PIC X(10).
           02  FILLER                        PIC X(14).
      *
       01  FLIPPED-FIRST-BYTES.
           02      HCL                       PIC X.
           02      HCH                       PIC X.
           02  FILLER                        PIC X(28).
           02  NKH                           PIC X.
           02  NKL                           PIC X.
       01  FLIPPED-KEY-BYTES.
           02  KSH                           PIC X.
           02  KSL                           PIC X.
           02  KOH                           PIC X.
           02  KOL                           PIC X.
           02  FILLER                        PIC X(10).
      /
       PROCEDURE DIVISION.
       RESET-COUNTER.
           MOVE ZERO TO COUNTER.
       DISPLAY-MESSAGE.
            DISPLAY "RM/COBOL File Generator for RMCCNV (Ver. 2.0B 12Jul
      -     "84)"
               LINE 1 ERASE.
           DISPLAY "This program generates the two copybooks"
               LINE 5 POSITION 18.
           DISPLAY "used when compiling RMCCNV - an indexed data file"
               POSITION 12.
           DISPLAY "conversion program. Information concerning the"
               POSITION 12.
           DISPLAY "indexed data file from which the records will be"
               POSITION 12.
           DISPLAY "converted will be displayed, and the user must"
               POSITION 12.
           DISPLAY "make any necessary corrections before executing"
               POSITION 12.
           DISPLAY "the program." POSITION 12.
           DISPLAY "Hit any key to continue" LINE 23 POSITION 30.
           ACCEPT RETURN-KEY POSITION 0.
       INPUT-FILENAME.
            DISPLAY "RM/COBOL File Generator for RMCCNV (Ver. 2.0B 12Jul
      -     "84)"
               LINE 1 ERASE.
           DISPLAY "(Cntrl-B for Back-Tab)" LINE 1 POSITION 56.
           DISPLAY "Original File Name? " LINE 2.
           ACCEPT FILE-NAME POSITION 0 TAB.
           IF FILE-NAME = SPACES GO TO INPUT-FILENAME.
       READ-HEADER.
           OPEN INPUT ISM-FILE.
           READ ISM-FILE RECORD INTO HEADER-FORMAT.
           CLOSE ISM-FILE.
           IF AUS-PER-HEADER > 255 OR AUS-PER-HEADER < 0
               MOVE CORRESPONDING FIRST-BYTES
                   TO FLIPPED-FIRST-BYTES
               MOVE FLIPPED-FIRST-BYTES TO FIRST-BYTES
               MOVE 1 TO FLIPPED-FLG
             ELSE MOVE 0 TO FLIPPED-FLG.
           PERFORM HEADER-OK-CHECK.
           IF HEADER-NOT-OK
               DISPLAY "Not Ver 1 Indexed file- " LINE 2 POSITION 40
               DISPLAY "Hit any key to continue" LINE 3 POSITION 40
               ACCEPT RETURN-KEY POSITION 0
               GO TO INPUT-FILENAME.
            IF FLIPPED-BYTES
               PERFORM RESET-COUNTER
               PERFORM FLIP-KEY-BYTES NUMBER-OF-KEYS TIMES.
       CONVERSION-ROUTINES.
           MOVE PRI-KEY-SIZE TO PRI-SIZE.
           MOVE PRI-KEY-OFFSET TO PRI-OFFSET.
           COMPUTE ALT-KEYS = NUMBER-OF-KEYS - 1.
           PERFORM RESET-COUNTER.
           PERFORM ALT-CONV ALT-KEYS TIMES.
      /
       INPUT-RECORD-SIZE.
           MOVE 1 TO I.
           DISPLAY "Bytes per Data Record  " LINE 2 POSITION 44.
           ACCEPT DATA-REC-SIZE POSITION 0 ECHO CONVERT TAB.
           IF DATA-REC-SIZE = 0 OR DATA-REC-SIZE > 4096
               PERFORM INPUT-ERROR-1.
       DISPLAY-HEADER-VALUES.
           DISPLAY "Bytes per Primary Key" LINE 3.
           DISPLAY PRI-SIZE LINE 3 POSITION 24.
           DISPLAY "Offset(Rel 0)" LINE 3 POSITION 30.
           DISPLAY PRI-OFFSET LINE 3 POSITION 45.
           DISPLAY "# of Alt Keys" LINE 3 POSITION 52.
           DISPLAY ALT-KEYS LINE 3 POSITION 67.
           MOVE ALT-KEYS TO ALT-NUMBER.
       DISPLAY-ALT-SPECS.
           PERFORM DISPLAY-ALT-VALUES ALT-NUMBER TIMES.
           MOVE 8 TO I.
           PERFORM CHECK-PAGE.
           DISPLAY "Working...." LINE 23 POSITION 30 ERASE EOS.
      *
       GENERATE-CODE-1.
           OPEN OUTPUT SEQ-COPYFILE-1.
           MOVE "       SELECT SCRATCH-FILE ASSIGN TO RAN"
               TO FIRST-40-1.
           MOVE "DOM ""SCRTCH.FIL"" " TO SECOND-40-1.
           WRITE SEQ-REC-1.
           MOVE "           ORGANIZATION IS BINARY SEQUENTIAL."
               TO SEQ-REC-1.
           WRITE SEQ-REC-1.
           MOVE "       SELECT OUT-FILE ASSIGN TO RANDOM "
               TO FIRST-40-1.
           MOVE "OUT-NAME" TO SECOND-40-1.
           WRITE SEQ-REC-1.
           MOVE "           ORGANIZATION IS INDEXED"
               TO SEQ-REC-1.
           WRITE SEQ-REC-1.
           MOVE "           ACCESS MODE IS RANDOM" TO SEQ-REC-1.
           WRITE SEQ-REC-1.
           MOVE "           RECORD KEY IS OUT-KEY" TO SEQ-REC-1.
           WRITE SEQ-REC-1.
           PERFORM RESET-COUNTER.
           PERFORM LIST-ALT-KEYS ALT-KEYS TIMES.
           MOVE "           FILE STATUS IS FILE-STATUS." TO SEQ-REC-1.
           WRITE SEQ-REC-1.
           CLOSE SEQ-COPYFILE-1.
      /
       GENERATE-CODE-2.
           OPEN OUTPUT SEQ-COPYFILE-2.
           MOVE "       FD  SCRATCH-FILE." TO SEQ-REC-2.
           WRITE SEQ-REC-2.
           MOVE "       01  SCRATCH-REC" TO SEQ-REC-2.
           PERFORM WRITE-PICS.
           MOVE DATA-REC-SIZE TO PIC-LENGTH.
           WRITE SEQ-REC-2.
           MOVE "       FD  OUT-FILE." TO SEQ-REC-2.
           WRITE SEQ-REC-2.
           MOVE "       01  OUT-RECORD." TO SEQ-REC-2.
           WRITE SEQ-REC-2.
           MOVE "           03  OUT-KEY-REC." TO SEQ-REC-2.
           WRITE SEQ-REC-2.
           PERFORM WRITE-PICS.
           IF PRI-OFFSET NOT = 0
               MOVE FILLER-LINE TO FIRST-40-2
               MOVE PRI-OFFSET TO PIC-LENGTH
               WRITE SEQ-REC-2.
           MOVE "               05  OUT-KEY" TO FIRST-40-2.
           MOVE PRI-SIZE TO PIC-LENGTH.
           WRITE SEQ-REC-2.
           COMPUTE EXTRA =
               DATA-REC-SIZE - ( PRI-SIZE + PRI-OFFSET ).
           IF EXTRA > 0 PERFORM WRITE-EXTRA.
           PERFORM RESET-COUNTER.
           PERFORM WRITE-ALTN-RECS ALT-KEYS TIMES.
           CLOSE SEQ-COPYFILE-2.
           DISPLAY "Copybooks Successfully Written" LINE 23 POSITION 40.
      *
       STOP-PARA.
           STOP RUN.
       EXIT-PARA.
           EXIT PROGRAM.
      /
       WRITE-ALTN-RECS.
           ADD 1 TO COUNTER.
           MOVE ALTN-LINE TO FIRST-24-2.
           MOVE COUNTER TO ALT-NUM.
           MOVE "REDEFINES OUT-KEY-REC." TO SECOND-40-2.
           WRITE SEQ-REC-2.
           PERFORM WRITE-PICS.
           IF ALT-OFFSET (COUNTER) NOT = 0
               MOVE FILLER-LINE TO FIRST-40-2
               MOVE ALT-OFFSET (COUNTER) TO PIC-LENGTH
               WRITE SEQ-REC-2.
           MOVE "               05  ALTN-" TO FIRST-24-2.
           MOVE COUNTER TO ALT-NUM.
           MOVE ALT-SIZE (COUNTER) TO PIC-LENGTH.
           WRITE SEQ-REC-2.
           ADD ALT-OFFSET (COUNTER) TO ALT-SIZE (COUNTER).
           COMPUTE EXTRA = DATA-REC-SIZE - ALT-SIZE (COUNTER).
           IF EXTRA > 0 PERFORM WRITE-EXTRA.
      *
       WRITE-PICS.
           MOVE "PIC X(" TO PIC-1.
           MOVE ").            " TO PIC-2.
      *
       WRITE-EXTRA.
           MOVE EXTRA TO PIC-LENGTH.
           MOVE FILLER-LINE TO FIRST-40-2.
           WRITE SEQ-REC-2.
      *
       FLIP-KEY-BYTES.
           ADD 1 TO COUNTER.
           MOVE CORRESPONDING KEY-BYTES (COUNTER)
               TO FLIPPED-KEY-BYTES.
           MOVE FLIPPED-KEY-BYTES TO KEY-BYTES (COUNTER).
      /
       ALT-CONV.
           ADD 1 TO COUNTER.
           IF ALT-KEY-SIZE (COUNTER) > 4096
               COMPUTE ALT-SIZE (COUNTER) =
                           ALT-KEY-SIZE (COUNTER) - 4096
               MOVE "Y" TO DUP-NUM (COUNTER)
           ELSE 
               MOVE ALT-KEY-SIZE (COUNTER) TO ALT-SIZE (COUNTER)
               MOVE "N" TO DUP-NUM (COUNTER).
           MOVE ALT-KEY-OFFSET (COUNTER) TO ALT-OFFSET (COUNTER).
      *
       HEADER-OK-CHECK.
            IF HEADER-CODE-WORD = -1
                   MOVE 1 TO HEADER-FLG
              ELSE MOVE 0 TO HEADER-FLG.
      *
       DISPLAY-ALT-VALUES.
           ADD 1 TO K.
           ADD 1 TO M.
           DISPLAY "Bytes per Alt Key #" LINE K.
           DISPLAY M LINE K POSITION 20.
           DISPLAY ALT-SIZE (M) LINE K POSITION 24.
           DISPLAY "Offset(Rel 0)" LINE K POSITION 30.
           DISPLAY ALT-OFFSET (M) LINE K POSITION 45.
           DISPLAY "Duplicates?" LINE K POSITION 52.
           DISPLAY DUP-NUM (M) LINE K POSITION 65.
      *
       LIST-ALT-KEYS.
           ADD 1 TO COUNTER.
           MOVE "           ALTERNATE RECORD KEY IS ALTN-"
               TO FIRST-40-1.
           MOVE COUNTER TO SECOND-40-1.
           WRITE SEQ-REC-1.
           IF DUP-NUM (COUNTER) = "Y" OR DUP-NUM (COUNTER) = "y"
               PERFORM WITH-DUPS.
      *
       WITH-DUPS.
           MOVE "                WITH DUPLICATES" TO SEQ-REC-1.
           WRITE SEQ-REC-1.
      /
       INPUT-ALT-SPECS.
           PERFORM ALT-KEY-SPECS ALT-NUMBER TIMES.
           IF M < ALT-NUMBER SUBTRACT M FROM ALT-NUMBER
               GO TO INPUT-ALT-SPECS.
           MOVE 0 TO ALT-NUMBER GO TO DISPLAY-ALT-SPECS.
       ALT-KEY-SPECS.
           ADD 1 TO M.
           ADD 1 TO K.
           PERFORM ALT-KEY-SPECS-1 THRU ALT-KEY-SPECS-3.
       ALT-KEY-SPECS-1.
           MOVE 5 TO I.
           DISPLAY "Bytes per Alt Key #" LINE K ERASE EOS. 
           DISPLAY M LINE K POSITION 20.
           ACCEPT ALT-SIZE (M) LINE K POSITION 24 CONVERT ECHO TAB 
               ON EXCEPTION DUMMY PERFORM I-BACK-TAB.
           IF ALT-SIZE (M) > 244 OR ALT-SIZE (M) = 0 OR
               ALT-SIZE (M) > DATA-REC-SIZE PERFORM INPUT-ERROR-1.
       ALT-KEY-SPECS-2.
           MOVE 6 TO I.
           DISPLAY "Offset(Rel 0)" LINE K POSITION 30.
           ACCEPT ALT-OFFSET (M) LINE K POSITION 45 CONVERT ECHO TAB 
               ON EXCEPTION DUMMY PERFORM I-BACK-TAB.
           ADD ALT-SIZE (M), ALT-OFFSET (M) GIVING ALT-TOTAL.
           IF ALT-TOTAL > DATA-REC-SIZE OR ALT-OFFSET (M) > 4095
               PERFORM INPUT-ERROR-1.
       ALT-KEY-SPECS-3.
           MOVE 7 TO I.
           DISPLAY "Duplicates? " LINE K POSITION 52 ERASE EOS.
           ACCEPT DUP-NUM (M) LINE K POSITION 65 TAB 
               ON EXCEPTION DUMMY PERFORM I-BACK-TAB.
           IF DUP-NUM (M) NOT = "Y" AND DUP-NUM (M) NOT = "y"
               AND DUP-NUM (M) NOT = "N" AND DUP-NUM (M) NOT = "n"
               PERFORM INPUT-ERROR-1.
           IF M = ALT-KEYS MOVE 0 TO ALT-NUMBER
               GO TO DISPLAY-ALT-SPECS.
      /
       I-BACK-TAB.
           IF DUMMY = 02
               MOVE M TO N MOVE K TO L
               GO TO U3, U3, U3, U3, U4-I, U5, U6 DEPENDING ON I
               ELSE PERFORM INPUT-ERROR-1.
       J-BACK-TAB.
           IF DUMMY = 02
               SUBTRACT 1 FROM J
               GO TO U1, U2, U3, U4-J, U5, U6 DEPENDING ON J
               ELSE PERFORM INPUT-ERROR-2.
       U4-I.
           IF K > 4 COMPUTE L = K - 1 COMPUTE N = M - 1 GO TO U7
               ELSE GO TO U4.
       U4-J.
           IF L > 4 SUBTRACT 1 FROM L SUBTRACT 1 FROM N GO TO U7
               ELSE GO TO U4.
       INPUT-ERROR-1.
           DISPLAY "Input Error !" LINE 23 POSITION 30.
           DISPLAY "Hit any key to start again" LINE 24 POSITION 30.
           ACCEPT RETURN-KEY POSITION 0.
           DISPLAY " " LINE 23 POSITION 30 ERASE EOS.
           GO TO INPUT-RECORD-SIZE, U4, U4, U4, ALT-KEY-SPECS-1,
               ALT-KEY-SPECS-1, ALT-KEY-SPECS-3 DEPENDING ON I. 
       INPUT-ERROR-2.
           DISPLAY "Input Error !" LINE 23 POSITION 30.
           DISPLAY "Hit any key to start again" LINE 24 POSITION 30.
           ACCEPT RETURN-KEY POSITION 0.
           DISPLAY " " LINE 23 POSITION 30 ERASE EOS.
           GO TO U1, U2, U2, U4, U5, U5, U7 DEPENDING ON J.
       CHECK-PAGE.
           DISPLAY "Is the above information correct ?"
               LINE 23 POSITION 30.
           DISPLAY "(Enter N to correct, any other key to continue)"
               LINE 24 POSITION 30.
           ACCEPT CORRECTION-KEY POSITION 0.
           IF CORRECTION-KEY = "N" OR CORRECTION-KEY = "n"
               DISPLAY " " LINE 23 POSITION 30 ERASE EOS
               GO TO U1.
      *
       U1.
           MOVE 1 TO J.
           ACCEPT DATA-REC-SIZE LINE 2 POSITION 67 UPDATE.
           IF DATA-REC-SIZE = 0 OR DATA-REC-SIZE > 4096
               PERFORM INPUT-ERROR-2.
      /
       U2.
           MOVE 2 TO J.
           ACCEPT PRI-SIZE LINE 3 POSITION 24 CONVERT ECHO UPDATE
               ON EXCEPTION DUMMY PERFORM J-BACK-TAB.
           IF PRI-SIZE > 244 OR PRI-SIZE = 0
               OR PRI-SIZE > DATA-REC-SIZE PERFORM INPUT-ERROR-2.
       U3.
           MOVE 3 TO J.
           ACCEPT PRI-OFFSET LINE 3 POSITION 45 CONVERT ECHO UPDATE
               ON EXCEPTION DUMMY PERFORM J-BACK-TAB.
           ADD PRI-SIZE, PRI-OFFSET GIVING PRI-TOTAL.
           IF PRI-TOTAL > DATA-REC-SIZE OR PRI-OFFSET > 4095
               PERFORM INPUT-ERROR-2.
       U4.
           MOVE 4 TO J.
           ACCEPT ALT-KEYS LINE 3 POSITION 67 CONVERT ECHO UPDATE
               ON EXCEPTION DUMMY PERFORM J-BACK-TAB.
           IF ALT-KEYS > 14 PERFORM INPUT-ERROR-2.
           MOVE ALT-KEYS TO ALT-NUMBER.
           IF ALT-NUMBER = 0 MOVE 0 TO N MOVE 3 TO L
               GO TO UPDATE-CHECK.
           IF M = 0 MOVE 3 TO K GO TO INPUT-ALT-SPECS.
           MOVE 1 TO N MOVE 4 TO L.
       U5.
           MOVE 5 TO J.
           IF N = M AND J > I GO TO ALT-KEY-SPECS-1.
           ACCEPT ALT-SIZE (N) LINE L POSITION 24 CONVERT ECHO
               UPDATE ON EXCEPTION DUMMY PERFORM J-BACK-TAB.
           IF ALT-SIZE (N) = 0 OR ALT-SIZE (N) > 244 OR
               ALT-SIZE (N) > DATA-REC-SIZE PERFORM INPUT-ERROR-2.
       U6.
           MOVE 6 TO J.
           IF N = M AND J > I GO TO ALT-KEY-SPECS-2.
           ACCEPT ALT-OFFSET (N) LINE L POSITION 45 CONVERT ECHO
               UPDATE ON EXCEPTION DUMMY PERFORM J-BACK-TAB.
           ADD ALT-SIZE (N), ALT-OFFSET (N) GIVING ALT-TOTAL.
           IF ALT-TOTAL > DATA-REC-SIZE OR ALT-OFFSET (N) > 4095
               PERFORM INPUT-ERROR-2.
       U7.
           MOVE 7 TO J.
           IF N = M AND J > I GO TO ALT-KEY-SPECS-3.
           ACCEPT DUP-NUM (N) LINE L POSITION 65
               UPDATE ON EXCEPTION DUMMY PERFORM J-BACK-TAB.
           IF DUP-NUM (N) NOT = "Y" AND DUP-NUM (N) NOT = "y"
               AND DUP-NUM (N) NOT = "N" AND DUP-NUM (N) NOT = "n"
               PERFORM INPUT-ERROR-2.
       UPDATE-CHECK.
           IF N = ALT-NUMBER
               MOVE N TO M MOVE L TO K MOVE 0 TO ALT-NUMBER
               ADD 1 TO L DISPLAY " " LINE L ERASE EOS
               GO TO DISPLAY-ALT-SPECS.
           IF N < M ADD 1 TO N ADD 1 TO L GO TO U5.
           IF N = M SUBTRACT M FROM ALT-NUMBER GO TO INPUT-ALT-SPECS.
      *
       END PROGRAM.
