|
|
Message Catalogs:Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 2 Creating an Application Message CatalogCreating a Source File |
|
A source file is an MPE ASCII file in an EDIT/V-compatible format created in your favorite editor. The catalog contains messages to be output to users. The messages are divided into logical groupings of sets. This section takes you through the tasks of:
A source catalog contains directives that partition information in the message catalog and indicate the beginning of each record. Directives are not printed out when the catalog is accessed and always begin in column one. There are three types of directives in a source file:
Blank lines are not allowed in a message catalog. Comments are used throughout the catalog to document sets and messages, and to make them easier to read. The format of a comment record, where comment is an optional string of characters is:
A space between $ and comment is optional. A $SET record initiates a logical grouping of messages. Sets break the catalog into manageable segments containing logical groupings of messages (for example, one set of messages for prompts, one set for instructions, one set for error messages). Each set is identified by a set number. Set numbers:
The format of a $SET record where setnum, an integer, is the required set number is:
The comment is an optional text string that must be separated from the set number by a blank. You may use $SET or $set, but not $Set or any variation of mixed cases. Examples of set directives are:
Note the use of a blank comment record for clarity. Message records contain the messages that are output to the user. Message records consist of a message number followed by the message text. This text may be an error message, prompt, or any text which may change according to the language or the country where the program will be used. Message record numbers:
For example, within a set, you can have messages 1-25, 101, 300-332, and 32,766. All of these message numbers can be used again in another set. The format for a message record where msgnum, an integer, is the required message number is:
The message text is an optional character string which follows the message number. If the text is not preceded by a blank, GENCAT replaces the character immediately following the message number with a blank and informs you that a blank has replaced the character. An exception is made if one of two special characters, "%" or "&," follow the message number. These characters will not be replaced by a blank. Their meaning is explained in the following section. An example of message records, set directives, and comments follows:
Special characters are used to control the format and content of messages when the messages are output.
Parameter substitutions are used to insert values that will be known at run time into your messages. An exclamation mark (!) is used within a message to indicate where the parameter is to be inserted. ! is treated as a special character; if you want to use an exclamation point in your message, use the tilde before it. You are allowed up to five parameter substitutions in each message. The parameters that are substituted are strings with an ASCII null as the last character. You may choose positional or numerical parameter substitution. Mixing these two types within a message is not allowed; if you do so, GENCAT will not create a formatted file. The CATREAD intrinsic, shown in the following examples, retrieves a message from the catalog and substitutes the necessary prarmeters. Using CATREAD is discussed in Chapter 3. Positional parameter substitution allows the parameters to be substituted from left to right. The example listed below will demonstrate the use of positional parameter substitution. Using the following values for parameter substitution:
Message 400 in set 13 is:
The execution of the CATREAD intrinsic call ... CATREAD (..., parm_1, parm_2, ...); results in the following message:
Numerical parameters allow the user to decide where the parameters are to be placed within the message. The exclamation mark (!) is immediately followed by a number in the range 1 through 5. Numerical parameter substitution is not generally used. It is useful when you rewrite your messages, or rearrange the parameters in the message, without changing the CATREAD call in the application. The example listed below demonstrates the use of numerical parameter substitution and uses the parameter definitions given above. Message 401 in set 13 is:
The execution of the same CATREAD intrinsic call as above (... CATREAD (..., parm_1, parm_2, ...);) results in the following message:
|
|