Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - Русский

Change language to:
English - Français - 日本語 - Português -

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Справка Scilab >> Dynamic/incremental Link > addinter

addinter

new functions interface dynamic link at run time.

Syntax

addinter(files, spname, fcts)

Arguments

files

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).

spname

a character string. Name of interface routine entry point

fcts

vector of character strings. The name of new Scilab function implemented in the new interface (in fin the order ).

Description

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.

Examples

if haveacompiler() then

chdir(TMPDIR);
mkdir('example_addinter');
chdir('example_addinter');

src = ['#include <math.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(0,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: 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()
Generated loader.sce with addinter
// This file is released under the 3-clause BSD license. See COPYING-BSD.
// Generated by builder.sce : Please, do not edit this file
// ----------------------------------------------------------------------------
//
addinter_path = get_absolute_file_path('loader.sce');
//
// ulink previous function with same name
[bOK, ilib] = c_link('addinter');
if bOK then
  ulink(ilib);
end
//
list_functions = [ 'fun1_in_scilab'];
//
// here we call addinter
addinter(addinter_path + filesep() + 'addinter' + getdynlibext(), 'addinter', list_functions);
// remove temp. variables on stack
clear addinter_path;
clear bOK;
clear ilib;
clear list_functions;
// ----------------------------------------------------------------------------

See also

  • link — dynamic linker
  • newfun — добавление имени в таблицу функций
  • clearfun — удаляет примитивы
  • api_scilab — api_scilab is the Scilab interface to read/write data from/to Scilab memory
Report an issue
<< Dynamic/incremental Link Dynamic/incremental Link c_link >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:55:07 CET 2020