HP 9000 User Manual page 115

Computers
Hide thumbs Also See for 9000:
Table of Contents

Advertisement

7
To retrieve messages,
catgets
uses an internal buffer that is overwritten
on each call. This is rarely a problem since a message is ordinarily used
immediately by being printed or tested. However, see "Special Considerations
for Messaging" later in this chapter.
Closing a Message Catalog
When the program no longer needs access to the message catalog, the
.
catalog file should be closed. This can be done with the
catclose
call but
it is generally simpler to let
exit
close the catalog file when the program
terminates.
Default Messages
A program should make provision for the case when the message catalog is not
available. This could happen, for example, if the file system containing the
catalog is not mounted or if there is no catalog for the current language. Note
that
catopen
does not take a default action if a catalog cannot be opened.
Provisions for default messages must be made by the program. There are two
general strategies for handling this situation:
• The "standard" method is to include the default message as the del_str in
the
catgets
call. If the
catopen
call fails, it returns
(nl_catd) -1,
an invalid
file descriptor. This subsequently causes
catgets
to fail and return del_str,
the default message. This is the recommended method of handling default
messages.
• Alternatively, you can use a default message catalog. Note that even
the default message catalog may not be available (e.g., if the file system
containing it were not mounted). Commands using this method should
consider the probability of this situation for their application and plan
accordingly. Applications that use this method often use error message
numbers as the default string in
catgets
calls.
If a message catalog is missing, it is seldom useful to issue an error message
unless it is reasonable to expect the catalog to be available. If a message
catalog is missing and the catalog is critical to the successful execution of the
program, it may be best to issue a message and terminate the program.
7·8
The Message Catalog System

Advertisement

Table of Contents
loading

Table of Contents