You can get the converted value of a data field or a memo field using fld_get(), and of a scrollable field using srf_get(). These functions read the contents of the edit buffer and convert it to the proper variable type for the field. They respect all data conversion options, including PICSKIP for string fields and TRAILBLANKS. The underlying data variable for the field is not changed unless it is used as the variable to place the contents of the field in.
The calls for these functions are as follows:
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Caution: This function expects a pointer to a variable of the proper type based on the field type. For string-based fields (string, time, and date, and memo fields), the string must be allocated, and it must be long enough to hold the converted string value of the field.
For example, if the PICSKIP option is set to ON, you can get the entry of a string field without the protected characters with the call:
|
where stringbuf is a pointer to a character buffer that you have defined and allocated. After the call the contents of stringbuf will contain the field entry minus the protected characters. Memory must be allocated for the character array, and it must be long enough to hold the converted field string.
To validate numeric fields, you will generally find it easier to ignore the field string passed to the validation function and to obtain the field value in converted format with:
|
You can operate directly on the data returned by fld_get() in numeric comparisons, without needing to make string to numeric conversions.