Changing the Contents of a Field

You can update the contents of a data field, memo field or scrollable region field by copying the contents of a data variable to the field. The data variable you specify can be the underlying data variable for the field or another data variable. This allows you to change the value displayed in other fields on the form while processing an item (for instance, when keeping a running total field).

To display a value in a data field or a memo field, call the field update function, fld_upd():

int fld_upd(varp, fld_or_memop, dfmp)
 
PTR varp;
/* Pointer to variable containing value to display
*/
FIELDPTR fld_or_memop;
/* Pointer to field or memo to update
*/
DFORMPTR dfmp;
/* Form being processed
*/

This option provides a means for you to write an event function that allows the user to select a previously written memo to display and edit in the field. For instance, you could write an event function that displays a data form that the user fills in with the name of the memo that he or she wants to edit. You would collect this information and use it to update the memo field with the appropriate memo.

To display a value in a scrollable field, call the scrollable region field update function, srf_upd():

int srf_upd(varp, data_row, data_col, srp)
 
PTR varp;
/* Ptr to variable containing value
*/
 
/* to display
*/
int data_row;
/* Data row of scrollable region
*/
int data_col;
/* Data column of scrollable region
*/
SRPTR srp;
/* Scrollable region
*/

Note that if the specified field in the scrollable region is not visible, the underlying data variable is updated. The field is not scrolled into view.

The above functions convert the contents of the variable pointed to in the call to a string for field display. All field options that are set for data conversion for the field are observed. The string is then copied to the form, at which time the user can edit the new field value. The field is flagged as having been altered but not validated and will not be validated until the user enters and leaves the field or the form is exited.

Caution: The data type of varp must correspond to the field type. To avoid compiler warnings, it should be cast to type PTR in the function call.


Home Contents Previous Next