callproc
callproc |
Purpose
Synopsis
int callproc(XPRMcontext ctx, XPRMproc proc, XPRMalltypes *parst);
Arguments
ctx
|
Mosel's execution context
|
proc
|
Reference to a routine (as returned by
findident or
getnextproc)
|
parst
|
An array containing the parameters for the routine
|
Return value
XPRM_RT_OK if execution succeeded, an error code otherwise (as returned by
XPRMrunmod).
Example
The following code extract shows how to call the function
mosfct(i:integer,r:real):boolean.
void callfct(XPRMcontext ctx) { XPRMalltypes fct,parst[2]; mm->findident(ctx, "mosfct", &fct); parst[1].integer=10; parst[0].real=5.5; mm->printf(ctx, "mosfct(10,5.5)="); mm->callproc(ctx, fct.proc, parst); mm->printf(ctx, "%d", parst[0].boolean); }
Further information
1. Execute the procedure or function
proc that is defined in a currently running model. The routine reference is obtained from
findident or
getnextproc. In the array
parst, the parameters for the function must be stored in reverse order. If the routine is a function, the return value is stored in the first cell of
parst.
2. If the procedure terminates by calling
exit(code), the return value is
XPRM_RT_EXIT and the exit code is stored in the first cell of
parst.
Related topics