Writing and Installing Scrollable Region Functions

Begin- and end-scrollable region and begin- and end-row scrollable region functions take a pointer to the current form and return an integer. The call is as follows:

int usr_func(dfmp)

DFORMPTR dfmp;        /* Form being processed        */

The editor passes the pointer to the form currently being processed. From this form pointer, you can get the pointer to the current scrollable region by calling cursrp(). You then have access to the current position in the scrollable region (row and column), a pointer to the current field in the scrollable region, the data entered by the user in the any field on the scrollable region or elsewhere on the form. You can get the pointer to any item on the form and make changes in the options or settings of the item. Functions are also provided to indicate to the editor what item you want to move to next and to set the next action code.

Your function should return TRUE on success and FALSE on failure. A return value of FALSE causes form processing to terminate immediately. In this case, the high-level processing function (fm_proc() or fm_rd()) will also make an immediate error return. You should reserve a FALSE return for unrecoverable errors.

To quit processing the form without saving the data that the user has entered, you can call sfm_nextitem() with the action code AC_QUIT. To exit from the form and save the data, you can call sfm_nextitem() with the action code AC_EXIT.

If your function fails, you can set the global error code VV_ERR to provide more information about the error to higher-level routines. You can use the existing error codes or add your own error codes and messages. See Chapter 50, "Debugging and Error Handling," for instructions on adding more error codes and error messages.

You can call the system event functions from within your scrollable region functions. This may be preferable, since you will not have to write code to handle many of the options settings. For instance, suppose you want to move to the last row of the scrollable region, you can simply call ks_end() the appropriate number of times.


Home Contents Previous Next