Advertisement
jelledebock

BABEL

Nov 10th, 2014
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 2.61 KB | None | 0 0
  1.  000001        IDENTIFICATION DIVISION.
  2.  000002        PROGRAM-ID. BABEL.
  3.  000003        ENVIRONMENT DIVISION.
  4.  000004        INPUT-OUTPUT SECTION.
  5.  000005        FILE-CONTROL.
  6.  000006              SELECT INP ASSIGN TO BABELIN.
  7.  000007        DATA DIVISION.
  8.  000008        FILE SECTION.
  9.  000009         FD INP.
  10.  000010         01 FILERECORD PIC X(80).
  11.  000011        WORKING-STORAGE SECTION.
  12.  000012        01 DICTREC.
  13.  000013           02 BAB   PIC X(20) OCCURS 1000 TIMES.
  14.  000014           02 NL    PIC X(20) OCCURS 1000 TIMES.
  15.  000015         01 FC.
  16.  000016          02 NDICT  PIC 9(4).
  17.  000017          02 NTRANS PIC 9(4).
  18.  000018          02 POINT  PIC 9(4) VALUE 1.
  19.  000019          02 ITER   PIC 9(4) VALUE 1.
  20.  000020          02 NEDR   PIC X(20).
  21.  000021          02 BABR   PIC X(20).
  22.  000022
  23.  000023        PROCEDURE DIVISION.
  24.  000024        MAIN.
  25.  000025               OPEN INPUT INP
  26.  000026               READ INP END-READ
  27.  000027               UNSTRING FILERECORD DELIMITED BY SPACES INTO NDICT NTRANS
  28.  000028               DISPLAY "READING " NDICT " ENTRIES FROM FILE"
  29.  000029               DISPLAY "TRANSLATING " NTRANS " ENTRIES FROM FILE"
  30.  000030               PERFORM FILLDICT VARYING POINT FROM 1 BY 1 UNTIL
  31.  000031                  POINT > NDICT
  32.  000032               MOVE 1 TO POINT
  33.  000033               PERFORM TRANSWRD VARYING POINT FROM 1 BY 1 UNTIL
  34.  000034                  POINT > NTRANS
  35.  000035               CLOSE INP
  36.  000036               STOP RUN
  37.  000037               .
  38.  000038        FILLDICT.
  39.  000039               READ INP END-READ
  40.  000040               UNSTRING FILERECORD DELIMITED BY SPACES INTO BAB(POINT)
  41.  000041                  NL(POINT)
  42.  000042               DISPLAY "RECORD: " NL(POINT) " IS IN BABELS " BAB(POINT)
  43.  000043               .
  44.  000044        TRANSWRD.
  45.  000045               MOVE 1 TO ITER
  46.  000046               MOVE "NULL" TO NEDR
  47.  000047               READ INP END-READ
  48.  000048               MOVE FILERECORD TO BABR
  49.  000049               DISPLAY "LOOKING UP " BABR
  50.  000050
  51.  000051               PERFORM UNTIL ITER > NDICT
  52.  000052                  DISPLAY "ITER= " ITER " POINTER " BAB(ITER) "?=" BABR
  53.  000053                  IF BAB(ITER) EQUAL TO BABR THEN
  54.  000054                    MOVE NL(ITER) TO NEDR
  55.  000055                    EXIT
  56.  000056                  END-IF
  57.  000057                  ADD 1 TO ITER
  58.  000058               END-PERFORM
  59.  000059
  60.  000060               IF NEDR EQUAL TO "NULL" THEN
  61.  000061                DISPLAY "???"
  62.  000062               ELSE
  63.  000063                 DISPLAY BABR
  64.  000064               END-IF
  65.  000065               .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement