 |
» |
|
|
|
This example shows the access of the sample catalog called FORMAT (created in the Chapter 2); the source of this sample catalog (SOURCE) is listed below.
$SET 1 Prompts
1 ENTER FIRST NAME
2 ENTER LAST NAME
$
$
$set 2 Error Messages
1 NAME NOT ON DATA BASE
2 ILLEGAL INPUT
3 AN ERROR OCCURRED DURING THE LOADING %
OF THE DATA BASE.
98 THE NUMBER OF FILES &
DOES NOT MATCH THE &
SYSTEM'S CALCULATIONS.
$
$set 13 Run-Time Messages
400 INPUT FROM ! ON TERMINAL NUMBER !
401 INPUT FROM TERMINAL NUMBER !2 BY !1
|
The program uses message 1 in set 1 to prompt for a first name, substitutes the name in message 400 of set 13, and outputs the message. All output is written to the terminal.
001000 IDENTIFICATION DIVISION.
001001 PROGRAM-ID. CATMSSG.
001003*
001004 ENVIRONMENT DIVISION.
001005 DATA DIVISION.
001006 WORKING-STORAGE SECTION.
001007 77 CAT-INDEX PIC S9(9) COMP.
001008 01 CAT-STATUS.
001009 03 CAT-STATUS-1 PIC S9(4) COMP.
001010 03 CAT-STATUS-2 PIC S9(4) COMP.
001011 77 CAT-FILE PIC X(20).
001012 77 MSGLENGTH PIC S9(4) COMP.
001013 77 SETNUM PIC S9(4) COMP.
001014 77 MSGNUM PIC S9(4) COMP.
001015 77 PARM-1 PIC X(5).
001016 77 ASCII-NULL PIC X VALUE %0.
001017 77 PARM-2 PIC X(1).
001018 77 ASCII-NULL-1 PIC X VALUE %0.
001019 77 MSGDESTINATION PIC S9(4) COMP.
|
001020*
001021 PROCEDURE DIVISION.
001022*
001023 START-OF-PROGRAM.
001024 PERFORM OPEN-A-CATATLOG.
001025 PERFORM READ-A-CATATLOG.
001026 PERFORM CLOSE-A-CATATLOG.
001027 STOP RUN.
001028*
001029 OPEN-A-CATATLOG.
001030 MOVE "FORMAT%" TO CAT-FILE.
001031 CALL INTRINSIC "CATOPEN" USING CAT-FILE,
001032 CAT-STATUS
001033 GIVING CAT-INDEX.
001034*
001035* CHECK CAT-STATUS FOR SUCCESS
001036*
001037 READ-A-CATATLOG.
001038 MOVE 1 TO SETNUM.
001039 MOVE 1 TO MSGNUM.
001040 MOVE 0 TO MSGDESTINATION.
001041 CALL INTRINSIC "CATREAD" USING CAT-INDEX,
001042 SETNUM,
001043 MSGNUM,
001044 CAT-STATUS,
001045 \\, \\,
001046 \\,
001047 \\, \\, \\, \\,
001048 MSGDESTINATION.
001051 ACCEPT PARM-1.
001052 MOVE '3' TO PARM-2.
001053 MOVE 13 TO SETNUM.
001054 MOVE 400 TO MSGNUM.
001055 CALL INTRINSIC "CATREAD" USING CAT-INDEX,
001056 SETNUM,
001057 MSGNUM,
001058 CAT-STATUS,
001059 \\, \\,
001060 PARM-1,
001061 PARM-2,
001062 \\, \\, \\,
001063 MSGDESTINATION.
001064*
001065* CHECK ERRORNUM FOR SUCCESS
001066*
001067 CLOSE-A-CATATLOG.
001068 CALL INTRINSIC "CATCLOSE" USING CAT-INDEX,
001069 CAT-STATUS.
001070*
001071* CHECK CONDITION CODE FOR SUCCESS
001072*
|
When this program is executed, the output is:
ENTER FIRST NAME
MARY
INPUT FROM MARY ON TERMINAL NUMBER 3
|
|