HPlogo Message Catalogs:Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 3 Accessing Application Message Catalogs

Reading Messages

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

The CATREAD intrinsic reads the message specified by the set and message number. When you use CATREAD to read messages, the message facility fetches the message from a message catalog, inserts parameters (if specified), and then routes the message to a file or returns the message in a buffer to the calling program. The syntax for the CATREAD intrinsic is:

 msglength := CATREAD (catindex, setnum, msgnum, catstatus,

 buffer, buffersize, parm1, parm2, parm3, parm4,

 parm5, msgdest); 

The functional return, msglength, receives the length of the message in bytes. The catindex parameter refers to the catalog identifier you received from CATOPEN. The parameters, setnum and msgnum specify the set and message number of the message to be output. The catstatus parameter tells you if the CATOPEN call resulted in error, and, if so, what the error is. The optional parameters, buffer and buffersize, give the buffer to put the message in and the size of the buffer, respectively. The substitution parameters, parm1 through parm5, contain character strings to be inserted into the message at run time. The file number to which the message may be sent is given in msgdest.

Parameter Substitution

Parameters may be inserted into the message read from the catalog. Parameter substitution is used when a message output contains information only known at run time. The parameters are passed to the message with the param1, param2, param3, param4, and param5 parameters in the CATREAD intrinsic and are inserted in the message wherever an "!" is found. Parameters are inserted from left to right in positional parameter substation and in the numerical position indicated in numerical parameter substitution. In either case, if param(n) is included in the CATREAD call, param(n-1) must be present (that is, you cannot specify param3 unless param1 and parm2 are specified. Refer to "Parameter Substitutions" in Chapter 2, for more information about parameter substitution. All substitutional parameters are passed as strings that must terminate with an ASCII null character.

Message Output

Messages may be output to a buffer or a file. If you output to a buffer, you specify the buffer and buffer size with the buffer and the buffersize parameters. To output to a file, you specify the file number (returned from HPFOPEN) and message length with the msgdest and the buffersize parameters. To output to $STDLIST, use a file number of 0 (zero).

To output message #400 from set #13 to $STDLIST, a call to the CATREAD intrinsic is done as follows:

     var 

       Msglength: SHORTINT; 

       Catindex : INTEGER;  {Returned by CATOPEN} 

       Setnum   : SHORTINT; 

       Msgnum   : SHORTINT; 

       Catstatus: Packed array [1..2] of SHORTINT; 

       Parm_1, 

       Parm_2   : STRING [ 5 ]; 

       Msgdest  : SHORTINT; 

       Dumy     : INTEGER; 



     Setnum := 13; 

     Msgnum := 400; 

     Msgdest := 0; {Output to $STDLIST} 

     Parm_1 := 'MARY'; 

     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)); 

     Msglength := CATREAD (Catindex, Setnum, Msgnum, 

        Catstatus,,, Parm_1, Parm_2,,,, Msgdest); 

For detailed information about the CATREAD intrinsic, refer to the MPE/iX Intrinsics Reference Manual (32650-90028).

Feedback to webmaster