Programming Guide


Validates data with a check digit function

int sm_ckdigit(int field_number, char *field_data, int occurrence, int modulus, int minimum_digits);

The field to validate. If field_number is 0, sm_ckdigit uses the data in field_data. If an error occurs and field_number is 0, no message is posted.

Specifies the data to validate. If field_data is null, the string to check is obtained from the field_number and occurrence and an error message is displayed if the string is bad.

The occurrence in field_number to validate.

Specifies the check digit algorithm to use. By default, sm_ckdigit supports mod 10 and mod 11 algorithms. For more information about the check digit algorithms, refer to the source code of sm_ckdigit that is distributed with Panther.

The minimum number of digits required by the check digit algorithm.



sm_ckdigit checks whether the data in field_data or occurrence contains the required minimum number of digits and ends with the proper check digit. This function is typically called by Panther at field validation; it uses the values in the field's Check Digit and Minimum Digits properties as arguments for parameters modulus and minimum_digits, respectively.

If you specify a field occurrence and its data is invalid, Panther issues an error message before returning. If you set field_number to 0 and supply invalid data for field_data, Panther does not issue any message.

You can install your own check digit function to replace sm_ckdigit. For more information on installing functions, refer to "Installing Functions" in the Application Development Guide.