lib - library definition
lib-dir: character string
lib-dir is a character string defining a directory that contains compiled Scilab function (.bin) files. In addition to these files lib-dir must have a file called names, that contains the names of the functions defined in lib-dir. On success, all functions in lib-dir are available from within Scilab. They are loaded on demand when called for the first time.
Binary files can be created from within Scilab with the command save.
Scilab's standard libraries are defined using lib on the SCIDIR/macros/* subdirectories.
As an example, given the following definitions
deff('z = myplus(x, y)', 'z = x + y') deff('z = yourplus(x, y)', 'x = x - y') lib_dir = '/home/joeuser/myscidir'
myplus and yourplus are compiled into lib_dir with the commands
save(lib_dir + '/myplus.bin', myplus) save(lib_dir + '/yourplus.bin', yourplus)
A library can now be created from the two .bin files with the command
xlib = lib(lib_path + '/')
xlib is a Scilab variable of type "library". A library variable usually is saved for later loading, either on-line or from the user-specific startup file ($HOME/.scilab).
Scilab tacitly assumes that file foo.bin defines only a single function named foo.
//define some variables function z = myplus(x, y), z = x + y,endfunction function z = yourplus(x, y), x = x - y,endfunction A=1:10; //creation des fichiers *.bin dans le repertoire libdir libdir=TMPDIR save(libdir + '/myplus.bin', myplus); save(libdir + '/yourplus.bin', yourplus); save(libdir + '/A.bin', A); //creation du fichier name mputl(['myplus';'yourplus';'A'],TMPDIR+'/names'); //creation de la bibliotheque contenant myplus et yourplus xlib = lib(libdir+'/') //effacement des variables clear myplus yourplus A //chargement automatique a l'execution myplus(1,2) A