IDENTIFICATION DIVISION. PROGRAM-ID. GRAPH200. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT DISK-INPUT-FILE ASSIGN TO "DISK_INPUT_FILE". SELECT DISK-OUTPUT-FILE ASSIGN TO "DISK_OUTPUT_FILE". / DATA DIVISION. FILE SECTION. FD DISK-INPUT-FILE RECORD VARYING FROM 1 TO 400 CHARACTERS DEPENDING ON WS-RECORD-LENGTH. 01 DISK-INPUT-REC. 05 FILLER PIC X(400). FD DISK-OUTPUT-FILE RECORD VARYING FROM 1 TO 400 CHARACTERS DEPENDING ON WS-RECORD-LENGTH2. 01 DISK-OUTPUT-REC PIC X(400). / WORKING-STORAGE SECTION. 01 WS-RECORD-LENGTH PIC 999 COMP VALUE 0. 01 WS-RECORD-LENGTH2 PIC 999 COMP VALUE 32. 01 WS-EOF PIC 9 VALUE 0. 01 WS-HEAD-ARRAY-TABLE. 05 WS-HEAD-ARRAY-T OCCURS 400 TIMES PIC X. 01 WS-COUNTER-1 PIC 999 VALUE 0 . 01 WS-COUNTER-2 PIC 999 VALUE 0. 01 WS-COUNTER-3 PIC 999 VALUE 0. 01 WS-COUNTER-4 PIC 999 VALUE 0. 01 WS-COUNTER-5 PIC 999 VALUE 1. 01 WS-COUNTER-6 PIC 999 VALUE 1. 01 SCOARRAY PIC X(256) VALUE SPACES. 01 WS-pointer PIC 999 VALUE 0. 01 WS-OUT-REC. 05 WS-FIRST-REC PIC X(15) VALUE SPACES. 05 FILLER PIC X VALUE "/". 05 WS-SECOND-REC PIC X(15) VALUE SPACES. 05 FILLER PIC X VALUE ";". 01 ws-quest pic x(400) value all "?". 01 WS-COUNTER-TABLE. 05 WS-COUNTER-T OCCURS 400 TIMES PIC 99 VALUE 0. 01 WS-ALPHA-TABLE. 05 WS-ALPHA-T OCCURS 64 TIMES PIC X. 01 WS-ALPHA-TABLE2. 05 WS-ALPHA-T2 OCCURS 95 TIMES PIC X. 01 WS-CHAR-TABLE. 05 WS-CHAR-T OCCURS 400 TIMES PIC X. 01 WS-CHAR-BUFF. 05 WS-BUFF-T OCCURS 400 TIMES PIC X. 01 WS-CHARACTERS. 05 FILLER PIC X(32) VALUE "?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^". 05 FILLER PIC X(32) VALUE "_`abcdefghijklmnopqrstuvwxyz{|}~". 01 WS-CHARACTERS-SOURCE. 05 FILLER PIC X(30) VALUE "!""#$%&'()*+,-./0123456789:;<=>". 05 FILLER PIC X(32) VALUE "?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^". 05 FILLER PIC X(32) VALUE "_`abcdefghijklmnopqrstuvwxyz{|}~". 01 WS-COUNT-TABLE. 05 WS-COUNT-T OCCURS 15 TIMES PIC 99 VALUE 0. 01 WS-OUTPUT-TABLE. 05 WS-OUTPUT-T OCCURS 24 TIMES PIC X(15). 01 WS-SPLIT. 05 WS-SPLIT-1 PIC X(15). 05 WS-SPLIT-2 PIC X(15). / PROCEDURE DIVISION. 000-MAIN-ROUTINE. MOVE WS-CHARACTERS TO WS-ALPHA-TABLE. MOVE WS-CHARACTERS-SOURCE TO WS-ALPHA-TABLE2. OPEN INPUT DISK-INPUT-FILE. OPEN OUTPUT DISK-OUTPUT-FILE. PERFORM 050-READ-ROUTINE UNTIL WS-EOF = 1. * DISPLAY SCOARRAY. MOVE 2 TO WS-RECORD-LENGTH2. MOVE "\" TO DISK-OUTPUT-REC. WRITE DISK-OUTPUT-REC. MOVE 4 to ws-record-length2. MOVE "(#1" TO DISK-OUTPUT-REC. write disk-output-rec. MOVE SCOARRAY TO DISK-OUTPUT-REC. MOVE WS-COUNTER-6 TO WS-RECORD-LENGTH2. WRITE DISK-OUTPUT-REC. MOVE 3 to ws-record-length2. MOVE "(B" TO DISK-OUTPUT-REC. write disk-output-rec. CLOSE DISK-INPUT-FILE. CLOSE DISK-OUTPUT-FILE. STOP RUN. / 020-IN-ORDER. MOVE 1 TO WS-COUNT-T (1). MOVE 2 TO WS-COUNT-T (2). MOVE 4 TO WS-COUNT-T (3). MOVE 8 TO WS-COUNT-T (4). MOVE 16 TO WS-COUNT-T (5). MOVE 32 TO WS-COUNT-T (6). / 020-IN-REVERSE. MOVE 1 TO WS-COUNT-T (6). MOVE 2 TO WS-COUNT-T (5). MOVE 4 TO WS-COUNT-T (4). MOVE 8 TO WS-COUNT-T (3). MOVE 16 TO WS-COUNT-T (2). MOVE 32 TO WS-COUNT-T (1). 050-READ-ROUTINE. perform 020-IN-ORDER. MOVE zeros TO WS-COUNTER-TABLE. move ws-quest to ws-char-table. PERFORM 055-READ-RECORD VARYING WS-COUNTER-2 FROM 1 BY 1 UNTIL WS-COUNTER-2 = 7. MOVE WS-CHAR-TABLE TO WS-CHAR-BUFF. MOVE zeros TO WS-COUNTER-TABLE. move ws-quest to ws-char-table. PERFORM 055-READ-RECORD VARYING WS-COUNTER-2 FROM 1 by 1 UNTIL WS-COUNTER-2 = 7. PERFORM 200-WRITE-RECORD VARYING WS-COUNTER-1 FROM 1 BY 1 UNTIL WS-COUNTER-1 > 20. MOVE " " TO SCOARRAY(WS-COUNTER-6:1). ADD 1 TO WS-COUNTER-6. MOVE " " TO SCOARRAY(WS-COUNTER-6:1). ADD 1 TO WS-COUNTER-6. 055-READ-RECORD. MOVE SPACES TO WS-HEAD-ARRAY-TABLE. IF WS-EOF = 0 THEN move spaces to disk-input-rec READ DISK-INPUT-FILE AT END MOVE 1 TO WS-EOF end-read MOVE DISK-INPUT-REC TO WS-HEAD-ARRAY-TABLE. PERFORM 110-EXTRACT-PIECES VARYING WS-COUNTER-3 FROM 1 BY 1 UNTIL WS-COUNTER-3 > WS-RECORD-LENGTH. 110-EXTRACT-PIECES. IF WS-HEAD-ARRAY-T (WS-COUNTER-3) = "@" THEN ADD WS-COUNT-T (WS-COUNTER-2) TO WS-COUNTER-T(WS-COUNTER-3) MOVE WS-COUNTER-T(WS-COUNTER-3) TO WS-POINTER ADD 1 TO WS-POINTER MOVE WS-ALPHA-T (WS-POINTER) TO WS-CHAR-T(WS-COUNTER-3). 200-WRITE-RECORD. MOVE WS-CHAR-BUFF TO WS-OUTPUT-TABLE. MOVE WS-OUTPUT-T (WS-COUNTER-1) TO WS-SPLIT-1. MOVE WS-CHAR-TABLE TO WS-OUTPUT-TABLE. MOVE WS-OUTPUT-T (WS-COUNTER-1) TO WS-SPLIT-2. MOVE WS-SPLIT-1 TO WS-FIRST-REC. MOVE WS-SPLIT-2 TO WS-SECOND-REC. MOVE WS-OUT-REC TO DISK-OUTPUT-REC. IF DISK-OUTPUT-REC NOT = "???????????????/???????????????;" THEN MOVE WS-ALPHA-T2 (WS-COUNTER-5) TO SCOARRAY(WS-COUNTER-6:1) ADD 1 TO WS-COUNTER-5 * display disk-output-rec WRITE DISK-OUTPUT-REC ELSE MOVE " " TO SCOARRAY(WS-COUNTER-6:1). ADD 1 TO WS-COUNTER-6.