HP 3000 Manuals

Example of Accessing an Application Message Catalog [ Message Catalogs:Programmer's Guide ] MPE/iX 5.0 Documentation


Message Catalogs:Programmer's Guide

Example of Accessing an Application Message Catalog 

This example shows the access of the sample catalog called FORMAT
(created in the last chapter); 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.

          Program MSGCAT (input,output);

          var
            Catindex   : INTEGER;
            Catstatus  : packed array [1..2] of CHAR;

          Function CATOPEN: INTEGER;  intrinsic;
          Function CATREAD: SHORTINT; intrinsic;
          Procedure CATCLOSE;         intrinsic;

          Procedure OPEN_A_CATALOG;
          {This procedure opens FORMAT}

          var
            Designator : packed array [1..7] of SHORTINT;

          begin
            Designator := 'FORMAT ';  {specify file name}
            Catindex := CATOPEN (Designator, Catstatus);
            {Call procedure to check Catstatus for errors}
          end;

          Procedure READ_A_CATALOG;
          {This procedure reads a message}
          {from FORMAT and prints it to  }
          {$STDLIST                      }

          var
            Setnum   : SHORTINT;
            Msgnum   : SHORTINT;
            Parm_1,
            Parm_2   : STRING [ 5 ];
            Dumy     : INTEGER;
            Msgdest  : SHORTINT;
            Msglength: SHORTINT;

          begin
            Msgdest := 0; {Output to $STDLIST}
            Setnum := 1;
            Msgnum := 1;
            Msglength := CATREAD (Catindex, Setnum, Msgnum,
               Catstatus,,,,,,,, Msgdest);
            {Call procedure to check Catstatus}
            Readln (Parm_1);
            Parm_2 :='3';

            {Append ASCII null}
            STRWRITE (Parm_1, (STRLEN(Parm_1)+1), Dumy, CHR(0));
            STRWRITE (Parm_2, (STRLEN(Parm_2)+1), Dumy, CHR(0));
            Setnum := 13;
            Msgnum := 400;   {Output operation message}
            Msglength := CATREAD (Catindex, Setnum, Msgnum,
               Catstatus,,, Parm_1, Parm_2,,,, Msgdest);
            {Call procedure to check Catstatus}
          end;

          Procedure CLOSE_A_CATALOG;
          {This procedure closes FORMAT}

          begin
            CATCLOSE (Catindex, Catstatus);
            {Call procedure to check Catstatus}
          end;

          begin  {main}
            OPEN_A_CATALOG;
            READ_A_CATALOG;
            CLOSE_A_CATALOG;
          end.

When this example is run, the output is as follows:

          ENTER FIRST NAME

          MARY

          INPUT FROM MARY ON TERMINAL NUMBER 3


MPE/iX 5.0 Documentation