next up previous
Next: Graphics Up: Introduction to SCILAB Previous: Change of variable

Calling external routine

Creating code of the external routine in Scilab
foo=['void foo(a,b,c)';
     'double *a,*b,*c;';
     '{ *c = *a + *b; }'  ];
Creating file, compiling and dynamic linking with the running Scilab
if getenv('WIN32','NO')=='OK' & getenv('COMPILER','NO')=='VC++' then
	unix_s('del foo.c')
	write('foo.c',foo);
	unix_s('nmake /f '+SCI+'/demos/intro/Makefile.mak ctarget TARGET=foo SCIDIR1='+strsubst(SCI,'/','\'))  //Compiling...(needs a compiler)
	link('foo.dll','foo','C')    //Linking to Scilab
else
	unix_s('rm -f foo.c');
	write('foo.c',foo);
	unix_s('make -f '+SCI+'/demos/intro/Makefile foo.o')     //Compiling...(needs a compiler)
	link('foo.o','foo','C');    //Linking to Scilab
end
Execution of the external routine
-->//5+7 by C function
-->fort('foo',5,1,'d',7,2,'d','out',[1,1],3,'d')
 ans  =
    12.


Scilab group