Concepts of Programming Languages

(Sean Pound) #1

survived without that mandate. The poor performance of the early compilers
simply made the language too expensive to use. Eventually, of course, compilers
became more efficient and computers became much faster and cheaper and had
much larger memories. Together, these factors allowed COBOL to succeed,
inside and outside DoD. Its appearance led to the electronic mechanization of
accounting, an important revolution by any measure.
The following is an example of a COBOL program. This program reads
a file named BAL-FWD-FILE that contains inventory information about a
certain collection of items. Among other things, each item record includes
the number currently on hand (BAL-ON-HAND) and the item’s reorder point
(BAL-REORDER-POINT). The reorder point is the threshold number of items
on hand at which more must be ordered. The program produces a list of items
that must be reordered as a file named REORDER-LISTING.


IDENTIFICATION DIVISION.
PROGRAM-ID. PRODUCE-REORDER-LISTING.


ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. DEC-VAX.
OBJECT-COMPUTER. DEC-VAX.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT BAL-FWD-FILE ASSIGN TO READER.
SELECT REORDER-LISTING ASSIGN TO LOCAL-PRINTER.


DATA DIVISION.
FILE SECTION.
FD BAL-FWD-FILE
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 80 CHARACTERS.


01 BAL-FWD-CARD.
02 BAL-ITEM-NO PICTURE IS 9(5).
02 BAL-ITEM-DESC PICTURE IS X(20).
02 FILLER PICTURE IS X(5).
02 BAL-UNIT-PRICE PICTURE IS 999V99.
02 BAL-REORDER-POINT PICTURE IS 9(5).
02 BAL-ON-HAND PICTURE IS 9(5).
02 BAL-ON-ORDER PICTURE IS 9(5).
02 FILLER PICTURE IS X(30).
FD REORDER-LISTING
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 132 CHARACTERS.


01 REORDER-LINE.


2.6 Computerizing Business Records: COBOL 61
Free download pdf