Linking Together Forms for Form Paging

The user can page from one form to another if you link forms together. When the user presses the Next Form key (assigned to Shift-F8, by default) the next form in the list is displayed. To get back to the previous form, the user presses the Previous Form key (assigned to Shift-F7, by default).

Designer: You can specify page links using the Designer. See the Designer User's Guide for details.

You are responsible for getting all of the linked forms from the Designer library yourself. If you have specified page links inside the Designer, you can use the Main Generator to generate the code to read and link the forms.

If you do not use the Main Generator and you have specified page links inside the Designer, you can use Vermont Views functions to determine what forms need to be read from the library. To get the name of the next or previous form, use fm_nextfmname() or fm_prevfmname():

UCHAR *fm_nextfmname(dfmp)

DFORMPTR dfmp;            /* Pointer to form        */



UCHAR *fm_prevfmname(dfmp)

DFORMPTR dfmp;            /* Pointer to form        */

These functions return a pointer to a form name, or NULLP if no previous form was specified in the Designer.

Caution: fm_nextfmname() and fm_prevfmname() work only for page links established in the Designer. They will not work for forms that were linked by calling sfm_link().

To determine whether the next or previous form has already been read from the Designer library, use the form name to pointer function fm_namptr():

FORMPTR fm_namptr(name_stp)

UCHAR *name_stp;        /* Name of form            */

fm_namptr() returns a pointer to the form with the specified name if that form is currently in memory. It returns NULLP if no form with the specified name is found.

You can also specify page links in your code, as described below, at any time after reading the forms from the Designer library.

Code: To create a page link, all forms must first be defined. The list of forms is created in code by calling the set form page link function, sfm_link():

void sfm_link(prev_dfmp, next_dfmp, dfmp)
 
DFORMPTR prev_dfmp;
/* Form to go to when user requests
*/
 
/* previous page
*/
DFORMPTR next_dfmp;
/* Form to go to when user requests
*/
 
/* next page
*/
DFORMPTR dfmp;
/* Pointer to form to insert into page list
*/

Specify NULLP for next_dfmp or prev_dfmp if you do not want to specify a next or previous form.

Note: If you specify page links in the Designer, you do not need to call sfm_link() in your code. Vermont Views will automatically link the forms during processing.

The following code example shows how to create a paging list for 5 forms:

DFORMPTR dfmp_1, dfmp_2, dfmp_3, dfmp_4, dfmp_5;

....

....                /* Define all forms (not shown)        */

sfm_link(NULLP, dfmp_2, dfmp_1);

sfm_link(dfmp_1, dfmp_3, dfmp_2);

sfm_link(dfmp_2, dfmp_4, dfmp_3);

sfm_link(dfmp_3, dfmp_5, dfmp_4);

sfm_link(dfmp_4, NULLP, dfmp_5);

You can make the list circular by specifying dfmp_5 as the previous form for form dfmp_1 and specifying dfmp_1 as the next form for form dfmp_5.


Home Contents Previous Next