Adding a New Validation Error Message

If one of the checks you perform in your field or form validation function fails, you should set the validation error code Validation:VAL_ERR and return FALSE.

The validation messages are defined in an array in Validation:vv_valmsg.c. The indexes to this array (the validation error codes) are #defined in Validation:vv_form.h. You can reference one of the system-defined validation error messages or add your own validation error code and message.

To add a message to the array, first #define a validation error code name for the validation error message. To allow for expansion of the system, the first validation error code you add should be #defined as Validation:VCSVALQ. The second should be #defined as VCSVALQ + 1, and so on. VCSVALQ is a #defined value for the number of validation error codes used by the system. By using VCSVALQ, you are ensured that you will not overlap any future additions to the validation error messages.

Next, you should add the message to the end of the validation message array located in Validation:vv_valmsg.c. This module should then be recompiled and replaced in the library.

By default, the error window used to display validation errors and other error messages is located on the bottom line of the screen and is only one line long. It has left and right margins of one character. Validation error messages should fit within this window, and so should be less than 78 characters in length. If you need to display longer messages, you will need to modify the size and location of the error window for the form. Each form has a pointer to the global error window ERR_WNP. You can modify the global error window, or create a separate error window and install it for a particular form. To install a new error window for a form, set the form structure member err_wnp to point to the new window. An example of this is:

fmp->err_wnp = new_err_wnp;

See Chapter 23, "About Windows," for more information about creating windows. See Chapter 25, "Changing the Appearance of Windows," for more information about modifying the size, location, and other attributes of a window.


Home Contents Previous Next