!JOB
!LIMIT (CORE,16)
!COBOL LS,DIAG,GO
       IDENTIFICATION DIVISION.
       PROGRAM-ID.  WORD-GUESS.
       AUTHOR.  ALAN C RUSK.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.  XEROX.
       OBJECT-COMPUTER.  XEROX.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT WORD-FILE ASSIGN TO DISC.
           SELECT PRINT-FILE ASSIGN TO PRINTER.
       DATA DIVISION.
       FILE SECTION.
       FD  WORD-FILE
           LABEL RECORD IS STANDARD
           DATA RECORD IS WORD.
       01  WORD.
           02  LETTER    PIC X OCCURS 12.
       FD  PRINT-FILE
           LABEL RECORD STANDARD
           DATA RECORD IS PRINT.
       01  PRINT.
           02  CARRIAGE  PIC X VALUE SPACE.
           02  PRINT-LINE PIC X(50).
       WORKING-STORAGE SECTION.
       77  GUESS         PIC X.
       77  BUFLEN        COMP VALUE 1.
       77  ANSWER        PIC X(3).
       77  BUFANS        COMP VALUE 3.
       77  SUB           COMP.
       77  FILEN         PIC X(11)  VALUE 'WORD-FILE   '.
       77  ACCTN         PIC X(8)  VALUE 'OCM47LHB'.
       77  LETTER-CNT    PIC 99.
       77  FLAG          PIC 9 VALUE 0.
           88  EOS       VALUE 1.
           88  EOG       VALUE 2.
           88  EOF       VALUE 5.
           88  END-SESSION VALUE 7.
       77  ASTERISKS     PIC X(12) VALUE '************'.
       01  MASK-WORD.
           02  MASK      PIC X OCCURS 12.
       PROCEDURE DIVISION.
       DO-IT.
           ENTER    SETFD WORD-FILE FILEN ACCTN.
           OPEN     INPUT  WORD-FILE
                    OUTPUT PRINT-FILE.
           CLOSE    PRINT-FILE
                    WORD-FILE.
           STOP RUN.
       DRIVER.
           MOVE     0 TO FLAG.
           PERFORM  SET-UP.
           PERFORM  MAIN UNTIL EOG.
           DISPLAY  'PLAY AGAIN?' UPON PRINTER.
           ENTER    REPLY ANSWER BUFANS.
           IF       ANSWER NOT = 'YES' MOVE 7 TO FLAG.
       MAIN.
           DISPLAY  'WHAT LETTER DO YOU GUESS'
                    UPON PRINTER.
           ENTER    REPLY GUESS BUFLEN.
           MOVE     0 TO FLAG.
           PERFORM  CHECK-LETTER
                    VARYING SUB
                    FROM 1 BY 1
                    UNTIL EOS OR SUB > 12.
           PERFORM  PRINT-INFO.
           IF       LETTER-CNT NOT < 12
                    MOVE 2 TO FLAG.
       CHECK-LETTER.
           IF       LETTER (SUB) = GUESS
               AND  MASK (SUB) = '*'
                    MOVE LETTER (SUB) TO MASK (SUB)
                    MOVE 1 TO FLAG
                    ADD 1 TO LETTER-CNT.
       PRINT-INFO.
           MOVE     SPACES TO PRINT-LINE.
           MOVE     MASK-WORD TO PRINT-LINE.
           WRITE    PRINT.
       SET-UP.
           READ     WORD-FILE
               AT END
                    MOVE 5 TO FLAG.
           MOVE     ASTERISKS TO MASK-WORD.
           MOVE     ZEROES TO LETTER-CNT.
!LOAD (GO),(UNSAT,(COBLIB)),(LMN,PROBE),(PERM)
