Creating the Data Form Information Array

dl_mnget() needs information about the data forms associated with the menu system in order to read the data forms from the library and resolve the external references made by these data forms. To do this, you must create an array of data form information structures (DFMINFO). The data form information structure has the following members:

typdef struct
   
{
   
    UCHAR *fmname_stp;
/* Name of form
*/
    PTR datastructp;
/* Pointer to data storage for form
*/
    FUNCLISTPTR funclistp;
/* Pointer to function list for form
*/
    MFILEPTR clist_mfp;
/* Pointer to choice list memory file
*/
} DFMINFO, *DFMINFOPTR;
   

Note that this is the same information that dl_fmget() needs to read a form from the library.

In the array, there needs to be one element for each data form associated with the menu system plus an element set to NULLP as an end of array marker. For example:

static DFMINFO fminfop[] =

{

    {"form1", &data1, des_tut, NULLP},

    {"form2", &data2, des_tut, NULLP},

    {"form3", &data3, des_tut, NULLP},

    {NULLP, NULLP, NULLP, NULLP}

};

The call to dl_mnget() would then be as follows:

top_mfmp = dl_mnget("top_level", SUBMENUS, des_tut, fminfop, libp);

The clist_mfp member of the DFMINFO structure should only be set when you have a menu that calls a form containing a choice list, a multi-toggle field, or a spin button. The steps for doing this are as follows:

In the example above, if you added a choice list to form2, you would add the call to mf_def() before calling dl_mnget(). If the ASCII text file were called clist.txt, the code would be:

int mf_rowq, mf_colq;



 
static DFMINFO fminfop[] =
 
{
 
    {"form1", &data1, des_tut, NULLP},

    {"form2", &data2, des_tut, NULLP},

    {"form3", &data3, des_tut, NULLP},

    {NULLP,   NULLP,  NULLP,   NULLP}
 
}



 
...

...



 
/* Determine how big the memory file should be                

mf_size("clist.txt", &mf_rowq, &mf_colq);



*/
/* Allocate memory file                                

mfp = mf_def(mf_rowq, mf_colq);



*/
/* Read memory file                                

mf_rd("clist.txt", mfp);



*/
/* Assign pointer to choice list memory file                

fminfop[1].clist_mfp = mfp;



*/
/* Read menus and associated data forms from Designer library        

top_mfmp = dl_mnget("top_level", SUBMENUS, des_tut, fminfop, libp);
*/

Note that, while you must call mf_def() before calling dl_mnget(), it is not necesary to call mf_rd() to read the memory file at this time. You can call mf_rd() at any point before processing the form with the choice list.


Home Contents Previous Next