Functions for handling parameters
In a Mosel program, parameters are accessed with the two subroutines setparam and getparam. The module must implement these two subroutines for its parameters.
The function that enables the user to set the parameters of our module is the following:
static int task_setpar(XPRMcontext ctx, void *libctx) { s_taskctx *taskctx; int n; taskctx=libctx; n=XPRM_POP_INT(ctx); switch(n) { case 0: taskctx->maxname=XPRM_POP_INT(ctx); break; case 1: taskctx->maxtime=XPRM_POP_REAL(ctx); break; default: mm->dispmsg(ctx, "Task: Wrong control parameter number.\n"); return XPRM_RT_ERROR; } return XPRM_RT_OK; }
Via its stack, Mosel provides the number of the parameter (value returned by the findparam service function) and its new value to the module.
The parameters of our module are accessed via the following function:
static int task_getpar(XPRMcontext ctx, void *libctx) { s_taskctx *taskctx; int n; taskctx=libctx; n=XPRM_POP_INT(ctx); switch(n) { case 0: XPRM_PUSH_INT(ctx, taskctx->maxname); break; case 1: XPRM_PUSH_REAL(ctx, taskctx->maxtime); break; default: mm->dispmsg(ctx, "Task: Wrong control parameter number.\n"); return XPRM_RT_ERROR; } return XPRM_RT_OK; }
The complete task module is part of the module examples provided with the Mosel distribution and on the Xpress website.