Programming Guide



sm_*fval

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.

Returns

Description

sm_fval performs validation on the specified field and returns the result. This function is called automatically when the cursor exits a field whose no_validation property is set to PV_NO. A field whose no_validation property is set to PV_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-7. Some are skipped if the field is empty or its valided property is set to PV_YES—that is, there is no data to verify or the data already passed verification.

Table 5-7 Property settings and field validation

Property setting Skip if valid Skip if empty

required = PV_YES

y

n

must_fill = PV_YES

y

y

regular_exp = expr

y

y

minimum_value = value

y

y

maximum_value = value

y

y

Check Digit = value*

y

y

data_formatting = PV_DATE_TIME

y

y

table_lookup = expr

y

y

data_formatting = PV_NUMERIC

y

y**

Validation Function*

n

n

Auto Field Function*

n

n

JPL Validation*

n

n

calculation

n

n

*Properties that are not accessible at runtime.
**If the field has a numeric format, the empty_format property also is tested.

You can force validation for an empty field by setting its required property to PV_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.

Example

// 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
...
}

See Also

sm_n_gval, sm_s_val, sm_validate