HP-UX Reference (11i v3 07/02) - 1 User Commands A-M (vol 1)

d
dspmsg(1) dspmsg(1)
nothing if the message cannot be retrieved from the catalog.
The following example displays message number 2 in set 3 of test.cat:
dspmsg -s 3 store.cat 2 ’Sorry, that item is no longer in stock.’
If dspmsg does not find the specified message in the catalog or cannot find or open the catalog, it displays
the string "Sorry, that item is no longer in stock."
Using Symbolic Names for Default Message Strings
When the mkcatdefs utility preprocesses a message source file, it can create a file that defines macros
or variables for default message strings. When this file is included in a shell script or program,
dspmsg
can specify a symbolic name for the default_string argument. In the following example the file containing
default message strings created by
mkcatdefs is first sourced in the POSIX shell. Then the
dspmsg
command is invoked using the name of one of these variables as the default message string.
. ./store_msg.sh
dspmsg -s 3 store.cat 2 "${STORE_SOLDOUT}"
The store_msg.sh file was created by the
mkcatdefs utility and defines the STORE_SOLDOUT variable
to be the string "Sorry, that item is no longer in stock." The
mkcatdefs utility created the variable name
by prepending the prefix (STORE_) that was specified with the
-p option to the symbolic name for the mes-
sage (SOLDOUT). See mkcatdefs(1) for more information about creating include files that define symbolic
names for default message strings.
Displaying Message Identifiers with Messages
The
dspmsg command displays a message by itself or preceded by its message identifier. Display of mes-
sage identifiers is enabled by one of the following:
1) The -e option, which must be combined with a setting for the CAT_MIDSET_
catname or
CAT_MIDSET environment variable and can be combined with a setting of the CAT_MIDFMT
environment variable. The catname is the name of the message catalog file in uppercase and
without the ".cat" extension. It overrides the CAT_MIDSET environment variable, if defined.
2) The -E option, which must be combined with a setting for the CAT_MIDFMT
environment vari-
able and is not affected by settings of the
CAT_MIDSET* environment variables.
Display of message identifiers is disabled under any of the following conditions:
1) For the -e option:
The CAT_MIDSET_ catname and CAT_MIDSET environment variables are not defined.
The value of the CAT_MIDSET_ catname or (if that variable is not defined) the value of the
CAT_MIDSET environment variable does not include the message set containing the message.
The value of the CAT_MIDSET_ catname or (if that variable is not set) the value of the
CAT_MIDSET environment variable is set to "", that is, NULL.
2) For the -E option:
The CAT_MIDFMT_ catname and CAT_MIDFMT environment variables are not defined.
3) For the -e and -E options:
The value of the CAT_MIDFMT_ catname or (if that variable is not defined) the value of the
CAT_MIDFMT environment variable is set to "", that is, NULL.
Message identifiers are made up of some combination of the catalog name, set identifier, message identifier,
and delimiting characters. Following are some examples of message identifiers you can display by using the
options and environment variables discussed in this manpage:
store/3/2: Sorry, that item is no longer in stock.
store 2: Sorry, that item is no longer in stock.
The first example illustrates the default format for message identifiers if you use the -e option and do not
set one of the CAT_MIDFMT* environment variables. The second example illustrates what happens when
you use the -E option and set the CAT_MIDFMT to "%C %M: ", that is, the catalog name followed by a
space followed by the message number.
The following subsections discuss the CAT_MIDSET* and CAT_MIDFMT* environment variables in more
detail.
242 Hewlett-Packard Company 2 HP-UX 11i Version 3: February 2007