Message Catalogs:Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 5 Accessing System Error Messages Accessing the CM Error Message Catalog |
|
The CM error message catalog, CATALOG.PUB.SYS, is read with the GENMESSAGE intrinsic; the catalog file is opened with HPFOPEN and closed with FCLOSE. Accessing any catalog that was formatted with MAKECAT.PUB.SYS is similar to accessing CATALOG.PUB.SYS. Title not available shows how intrinsics are used to access the CM error message catalog. CATALOG.PUB.SYS must be opened as a permanent ASCII file with buffering inhibited and multirecord mode (PERMANENT (OLD), ASCII, NOBUF, MULTI). You use HPFOPEN to open the catalog. HPFOPEN returns the file number for CATALOG.PUB.SYS. This file number is a required parameter for the GENMESSAGE intrinsic. The HPFOPEN intrinsic is the most efficient way to open a file for access. When using the HPFOPEN intrinsic, the parameters are:
To open CATALOG with HPFOPEN:
Filenum returns the file number for CATALOG.PUB.SYS; Status returns a value that indicates if the intrinsic call was successful. If it was not successful, Status gives you information about the error. For detailed information about the HPFOPEN intrinsic, refer to the MPE XL Intrinsics Reference Manual (32650-90028). Use the GENMESSAGE intrinsic to read messages from CATALOG.PUB.SYS. Call GENMESSAGE with the file number for CATALOG.PUB.SYS, a set number, a message number, and any values to be substituted in the message. When you use GENMESSAGE 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 GENMESSAGE intrinsic is:
The parameters param1 ... param5 are used to substitute values in the message at run time. 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, such as a ldev number or a session name. Parameters are passed to the message with the param1, param2, param3, param4, and param5 parameters in the GENMESSAGE intrinsic and are inserted in the message wherever a "!" is found. Parameters are inserted in the following order: param1 substitutes for the leftmost "!" in the message, param2 for the next ! to the right, and so forth. If param(n) is present, param(n-1) must be present (that is, you cannot specify param3 unless param1 and param2 are specified). To specify the format of each of your parameters, use the parmask parameter of the GENMESSAGE intrinsic. The parmask parameter indicates the format of each of the five substitution parameters. Three bits describe the data type for each of these parameters. With bit zero being the leftmost bit, the value of parmask is represented as follows:
These bit values are as follows:
The positions of the bit values given above, indicate which substitution parameter's data type is being specified. For example, parmask = OCTAL ('13333') denotes that the first parameter is passed as a 16-bit signed integer, and all other parameters are ignored.
Messages may be output to a buffer or a file. If you output to a buffer, you specify the buffer and a buffer size with the buffer and the buffersize parameters. To output to a file, you specify the file number and message the buffersize parameters. To output to $STDLIST, use a file number of 0 (zero). To output message #210 from set #1 to $STDLIST, use GENMESSAGE to access CATALOG.PUB.SYS in the following manner:
For detailed information about the GENMESSAGE intrinsic, refer to the MPE/iX Intrinsics Reference Manual (32650-90028). To close the CM error message catalog, use the FCLOSE intrinsic. Close the catalog with the same domain as when opened (PERM) with unrestricted access.
For detailed information about the FCLOSE intrinsic, refer to the MPE/iX Intrinsics Reference Manual (32650-90028). The following listing is a Pascal program that inserts the value 95 into message number 201 in message set 1 in the message catalog CATALOG.PUB.SYS. The message is output to $STDLIST. The accessed portion of the message catalog is:
When this program is executed, the output is:
|