Specifications for a Range Setting Function
The range setting function must be an integer function and return TRUE if the range structure was successfully initialized and return FALSE if an error occurred.
A range setting function must accept three parameters: the first parameter is a pointer to the minimum value, the second parameter is a pointer to the maximum value, and the third parameter is a pointer to a data field structure.
The definition for a range setting function is as follows:
int rgset_func(minp, maxp, dfldp)
|
|
PTR *minp;
|
/* Pointer to minimum value
|
*/
|
PTR *maxp;
|
/* Pointer to maximum value
|
*/
|
DFIELDPTR dfldp;
|
/* Pointer to field structure
|
*/
|
The steps you must take in this function are as follows:
- nIf the minimum and maximum values are both zero and the structure exists (i.e.,
dfldp->rangep holds a pointer), free the structure and set dfldp->rangep to NULLP.
- nIf a range is specified for the field and there is no range structure pointed to in the field structure, allocate memory for the range structure based on the size of the range structure specified in the field type structure. If there is insufficient memory to allocate the structure, the range setting function should return FALSE. You should also set the error code VV_ERR to MEMLACK.
- nCopy the value of the minimum value to the first member of the range structure for the field type.
- nCopy the value of the maximum value to the second member of the range structure for the field type.
- nAssign a pointer to the initialized range structure to the field structure member
dfldp->rangep. The system validation function should reference this initialized range structure when checking that the field value is within the valid range.