home *** CD-ROM | disk | FTP | other *** search
- COBOL Software Review
-
- Rich Rohde
- Portland IBM PC Users Group
-
- I have had an opportunity to evaluate
- COBOL for the IBM Personal Computer.
- This version of COBOL conforms to the
- "Low-Intermediate" level of the
- American National Standard
- X3.23-1974. There are several
- features of this COBOL version which
- I would like to review.
-
- IBM COBOL performs processing and
- management of sequential, relative
- and indexed I/O (ISAM) files. The
- LINAGE clause for print files is also
- provided. Although not directly
- stated, some form of communication is
- provided by specifying COM1 in the
- VALUE OF FILE-ID clause in the file
- description.
-
- Interprogram communications are
- handled by two methods. The first
- method is the use of the CALL
- statement passing parameters to the
- called program, where the called
- program must have a LINKAGE SECTION
- and a USING phrase on the PROCEDURE
- DIVISION statement. The program also
- must include an EXIT PROGRAM
- statement, as opposed to a STOP RUN,
- to return to the calling program. The
- second method is to use the CHAIN
- statement, where the called program
- is a link-edited executable program.
- When the CHAIN statement is used, the
- complete file name must be specified,
- including the file extension.
-
- SORT/MERGE and REPORT WRITER are not
- supported.
-
- Segmentation is supported so larger
- programs can be divided into
- overlays. Before you call an overlay
- (independent segments 50 to 99) all
- files must be closed and all I/O must
- be performed in the segment. In an
- attempt to use segmentation I found
- that the DISPLAY screen name and
- ACCEPT screen name did not work in
- the segment. To get around this
- undocumented situation, I used the
- DISPLAY and ACCEPT statement prior to
- segmentation.
-
- The feature I found most attractive
- was the SCREEN SECTION. Within this
- section, you are able to totally
- define an output screen with row,
- column, underline, reverse video and
- high intensity. With a graphics
- display, colors may be used. The
- definition of data to be displayed
- from another data name is supported.
- To have a defined display appear on
- your screen, simply use the DISPLAY
- statement. Data names also may be
- included to tell COBOL where data
- being accepted from the screen is to
- go.
-
- Programs written in IBM Personal
- Computer COBOL require the COBRUN.EXE
- runtime module. If you are writing
- applications to be distributed, a
- license agreement with IBM will be
- needed. IBM indicates the license
- agreement can be readily obtained.
-
- In the FILE-CONTROL, you may specify
- in the SELECT clause a FILE STATUS
- data name phrase. The data name must
- be defined in the WORKING-STORAGE
- SECTION as a PIC X(2). I had defined
- the file status as a PIC 9(2) and
- received the compile error message
- "UNRECOGNIZABLE ELEMENT IS IGNORED".
- With the line number of the error was
- that of the PROCEDURE DIVISION.
-
- One problem I am aware of in the
- COBOL compiler concerns with the
- order in which data is moved to a
- field in a record. This can be solved
- easily as the following example
- illustrates.
-
- FILE-CONTROL.
- SELECT PARAM-FILE ASSIGN TO DISK
- FILE STATUS IS STATUS-FLAG
- ACCESS MODE IS DYNAMIC
- ORGANIZATION IS RELATIVE
- RELATIVE KEY IS PARAM-RECORD-KEY.
-
- FD PARAM-FILE
- VALUE OF FILE-ID 'PARAM.DAT'
- LABEL RECORDS ARE STANDARD.
- 01 PARAM-RECORD.
- 05FIELD-1 PIC X.
- 05FIELD-2 PIC 9(4) COMP-3.
-
- WORKING-STORAGE SECTON.
- 01 STATUS-FLAG PIC X(2).
- 01 PARAM-RECORD-KEY PIC 9.
-
- PROCEDURE DIVISION.
- DECLARATIVES.
- PARAM-FILE-ERROR SECTION.
- USE AFTER EXCEPTION ON PARAM-FILE.
- DISPLAY-STATUS-FLAG.
- IF STATUS-FLAG = '30'
- CLOSE PARAM-FILE
- OPEN OUTPUT PARAM-FILE
- MOVE SPACES TO FIELD-1
- MOVE ZEROS TO FIELD-2
- MOVE 1 TO PARAM-RECORD-KEY
- WRITE PARAM-RECORD
- CLOSE PARAM-FILE
- OPEN INPUT PARAM-FILE.
- END DECLARATIVES.
- MAIN-SECTION SECTION.
- MAIN-PROCEDURE.
-
- OPEN I-O PARAM-FILE.
- MOVE 1 TO PARAM-RECORD-KEY.
- READ PARAM-FILE RECORD.
-
- In the example, if the file PARAM.DAT
- does not exist, an error will occur
- when opening the file as I-O and the
- DECLARATIVES will be performed. As
- you can see, the file is closed and
- then reopened as OUTPUT, the data
- record initialized and the record
- number one written. Control is
- returned to the main line with the
- file as I-O and the record is read,
- but an error is encountered with the
- STATUS-FLAG containing a '23' (no
- record found).
-
- After checking the actual contents of
- record number one by using DEBUG and
- finding that FIELD-1 was null, I
- reversed the order in which the
- record was initialized:
-
- MOVE ZEROS TO FIELD-2
- MOVE SPACES TO FIELD-1
-
- and reran the program with complete
- success.
-
- This version is as powerful as the
- COBOL on larger systems and close to
- being 100 percent compatible. I would
- strongly recommend its purchase for
- business applications.