Initializing help system before first use

Structures for passing information

Our module needs to do the following:

  • retrieve any necessary information from Mosel
  • initialize itself
  • define the new subroutine
  • pass the new subroutine on to Mosel

To start with, we shall look at the structures that are required for exchanging information.

List of subroutines

The library function that implements the new subroutine will be called ar_getsol. This function and a standardized description of the subroutine it implements must be put into a list of subroutines that is passed to Mosel:

static XPRMdsofct tabfct[]=
    {
     {"solarray", 1000, XPRM_TYP_NOT, 2, "A.vA.r", ar_getsol}
    };

The entries of the subroutine description are the following:

  • the name of the new subroutine (in a Mosel program),
  • its order number within the module (not less than 1000),
  • the type of the return value (here: none, we implement a procedure),
  • the number and type(s) of the parameters (here: A.v: an array of variables and A.r: an array of reals), and
  • the name of the C function that implements it.

A complete description of the possible values for the entries of this list is given in Section List of subroutines.

Interface structure

The list of subroutines in turn needs to be put into the interface structure. Since no constants, services or types are defined by this module all other entries of this structure remain empty:

static XPRMdsointer dsointer=
    {
     0, NULL,
     sizeof(tabfct)/sizeof(XPRMdsofct), tabfct,
     0, NULL,
     0, NULL
    };

Initialization function

The module initialization function is almost the same as in the previous example, except for its name which must correspond to the name of the module:

DSO_INIT solarray_init(XPRMnifct nifct, int *interver,int *libver,
                       XPRMdsointer **interf)
{
 mm=nifct;                  /* Get the list of Mosel NI functions */
 *interver=XPRM_NIVERS;     /* Mosel NI version */
 *libver=XPRM_MKVER(0,0,1); /* Module version */
 *interf=&dsointer;         /* Pass info about module contents to Mosel */
 return 0;
}

Note that in this example — as opposed to the previous one — we are going to use functions of the Native Interface and therefore need to obtain the list of these functions from Mosel (mm is of type XPRMnifct).

© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.