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);
field_number
- The field to validate. If
field_number
is 0,sm_ckdigit
uses the data infield_data
. If an error occurs andfield_number
is 0, no message is posted.field_data
- Specifies the data to validate. If
field_data
is null, the string to check is obtained from thefield_number
andoccurrence
and an error message is displayed if the string is bad.occurrence
- The occurrence in
field_number
to validate.modulus
- 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 ofsm_ckdigit
that is distributed with Panther.minimum_digits
- The minimum number of digits required by the check digit algorithm.
- 0 The value of
field_number
orfield_data
is valid.
- -1 The field contents lack the minimum number of digits or proper check digit.
- -2
field_data
is null and the field or occurrence cannot be found.
sm_ckdigit
checks whether the data infield_data
oroccurrence
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 parametersmodulus
andminimum_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 forfield_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.