addinter — new functions interface dynamic link at run time.
addinter(files,spname,fcts)
a character string or a vector of character string contain object files used to define the new Scilab interface routine (interface code, user routines or libraries, system libraries).
a character string. Name of interface routine entry point
vector of character strings. The name of new Scilab function
implemented in the new interface (in fin
the
order ).
addinter
performs dynamic link of a compiled C or
Fortran new Scilab interface routine and define corresponding scilab
functions.
You can use the command link('show')
to get the
number of the shared libraries. And to reload a new version of an
interface a call to ulink
is necessary to get rid of
the old version.
See link
for more precision on use.
Number of 'addinter' in a scilab session can be limited by the operating system. On Windows, you cannot load more than 80 dynamic libraries at the same time.
Number of functions implemented in a interface is limited to 1000.
if haveacompiler() then chdir(TMPDIR); mkdir('example_addinter'); chdir('example_addinter'); src = ['#include <math.h>' '#include <stack-c.h>' '#include <api_scilab.h>' '#include <Scierror.h>' '#include <localization.h>' '' 'static double fun2(double x);' '' 'void fun1(double *x,double *y) ' '{' ' *y=fun2(*x)/(*x); ' '} ' '' 'static double fun2(double x)' '{ ' ' return( sin(x+1));' '}' '' 'int sci_fun1(char *fname)' '{' ' int iType1 = 0;' ' SciErr sciErr;' ' int m1 = 0, n1 = 0;' ' double *pdVarOne = NULL;' ' int *piAddressVarOne = NULL;' '' ' CheckRhs(1,1);' ' CheckLhs(1,1);' '' ' sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);' ' if(sciErr.iErr)' ' {' ' printError(&sciErr, 0);' ' return 0;' ' }' '' ' sciErr = getVarType(pvApiCtx, piAddressVarOne, &iType1);' ' if(sciErr.iErr)' ' {' ' printError(&sciErr, 0);' ' return 0;' ' }' '' ' if (iType1 != sci_matrix)' ' {' ' Scierror(999,_(""%s: Wrong type for input argument #%d: A string expected.\n""), fname, 1);' ' return 0;' ' }' '' ' sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarOne, &m1, &n1, &pdVarOne);' ' if(sciErr.iErr)' ' {' ' printError(&sciErr, 0);' ' return 0;' ' }' '' ' fun1(pdVarOne, pdVarOne);' ' LhsVar(1) = 1;' ' return 0;' '}']; mputl(src,TMPDIR + '/example_addinter/example_addinter.c'); files=['example_addinter.c']; ilib_build('addinter',['fun1_in_scilab','sci_fun1'],files,[]); disp(mgetl('loader.sce')); exec loader.sce; fun1_in_scilab(%pi) end // if haveacompiler()