Programming Guide |
Forces validation for the specified object
int sm_validate(int obj_id);int sm_n_validate(char *widget_name);
obj_id
- Object ID of the widget or screen to be validated, obtained from sm_prop_id
widget_name
- The name of the widget to validate. For fields, an occurrence number or element number can be included. For example,
sm_n_validate "field[[3]]")
causes the third element of the named field to be validated.
sm_validate
causes the specified widget or screen to be validated. The specified widget must be on the current screen.The widget must be one of the following types:
- A field that is not a card. When
sm_n_validate
is called,widget_name
can specify an occurrence or an element to validate. If not specified, the first element is validated.
- A tab card. Each field, grid and tab card in the card is validated.
- A tab deck. Each tab card in the deck is validated.
- A screen. This is the same as calling sm_s_val except that the flag
K_USER
rather thanK_SVAL
is passed to the validation functions.
Validation stops when a field fails validation or when a validation function returns a non-zero value. See
sm_fval
for more about field validation and sm_s_val for more about screen validation.
#include <smdefs.h>
/* Call a grid validation function and return if it fails.
*/
int
validate (fieldnum, data, occurrence, bits)
int fieldnum, occurrence, bits;
char *data;
{
if (sm_n_validate("grid1")
{
/* Stop processing if grid validation function fails */
return 1;
}
...
}