The message file for a data entry application stores the error message text that is displayed during data entry. The message file for a batch application stores the error message text that will be included in the execution report. The message file has the extension .mgf. While creating your application, you can view the message text in a window at the bottom of the logic screen.
You can associate multiple message files with an application, which can be useful if you have messages defined in multiple languages. To do this, select File -> Add Files
and then choose the external message file to add to the application. If you no longer want to use the external message file, you can remove it by selecting File -> Drop Files
. If the name of the external message file begins with CSProRuntime
, then the messages in that file will override the CSPro system messages.
Each line in the message file contains one message. A message consists of a message number followed by text. The message text can be up to 240 characters long. It is displayed on the entry screen when an errmsg
function with the message number is executed in a data entry application. It is written to the execution report when errmsg
function with the message number is executed in a batch application. The messages can also be accessed with other functions (including maketext
For example, suppose a message file contains the following lines:
1 This is the first message
2 This is the second message
When an errmsg(1)
function is executed in a data entry application, the message "This is the first message" is displayed on screen. When an errmsg(2)
function is executed, the message "This is the second message" is displayed.
Parameters can be specified in the errmsg
function. These parameters
can be numeric expressions or string expressions. String parameters in the error message text are indicated by %s
. Integer numeric parameters are indicated with %d
. Decimal numeric parameters are indicated with %f
. For example, a message file might contain the following:
1 The month of %s has only %d days. You entered %d!
The application could use this as follows:
When the function is executed, it knows to use error message 1 and substitute the word "June" for %s in the message text, the number 30 for the first %d, and the number 31 for the second %d. The message "The month of June has only 30 days. You entered 31!" will be displayed on the screen.
The more general the parameters of the message, the more flexible the message. In the example below, the value of the variable HHDAY is used as a parameter. The error message will use the value of HHDAY
if the errmsg
function is executed.
When designing an application that will be used in multiple languages
, you can define multiple messages for a given message number. Use the language name
, followed by the message number in parentheses, as shown in this example:
CSPro will automatically display the correct message based on the current language. If no translated message exists for the current language, the default message is shown.
Using the Language directive declares that all subsequent error messages are in a given language. For example, the previous example could be rewritten as:
You can also use the message file to translate string literals that are used along with the tr
function. For example:
in logic will display the correct string based on the current language.