Programming Guide |
Forces field validation
int sm_fval(int field_number);int sm_e_fval(char *array_name, int element);int sm_i_fval(char *field_name, int occurrence);int sm_n_fval(char *field_name);int sm_o_fval(int field_number, int occurrence);
field_name
field_number- The field to validate.
element
- The element in
field_name
to validate.occurrence
- The occurrence in the specified field to validate.
- 0 The field data is valid, or the field's
no_validation
property is set toPV_YES
.
- -1 Unable to find the validation function specified for this field.
sm_fval
performs validation on the specified field and returns the result. This function is called automatically when the cursor exits a field whoseno_validation
property is set toPV_NO
. A field whoseno_validation
property is set toPV_YES
never undergoes validation processing. When called for a tab card,sm_fval
first validates all the widgets on that card and then calls the card's validation function. To perform validation on all screen fields, call sm_s_val.During field validation, Panther tests a field's data against a number of formatting and input property settings, in the order shown in Table 5-9. Some are skipped if the field is empty or its
valided
property is set toPV_YES—
that is, there is no data to verify or the data already passed verification.
You can force validation for an empty field by setting its
required
property toPV_YES
. If a field has embedded characters, Panther performs validation if it contains at least one character that is neither blank nor punctuation; otherwise, it treats the field as empty. Math expressions, JPL functions and field validation functions are never skipped, because they are liable to modify other fields.Field validation is performed automatically within sm_input when the cursor exits a field. sm_s_val validates all fields on a screen during screen exit. Applications should call this function only to force validation of other fields. Field validation is also performed when
sm_fval
or sm_validate is called to validate a tab card or tab deck of which the field is a member.
// Verify that the previous field is valid before using
// the data in the current one
proc validate(fieldnum, data, occurrence, bits)
{
if (sm_fval(fieldnum - 1))
{
// Put cursor in the previous field to show error
call sm_gofield(fieldnum - 1);
return 1;
}
// otherwise process this field's data
...
}
sm_n_gval, sm_s_val, sm_validate