genlib
build library from functions in given directory
Calling Sequence
genlib(lib_name [[,dir_name, [ Force [,verb [,Names]]]]) genlib(lib_name [,path=dir_name] [,verbose=verb] [,force=Force] [,names=Names])Arguments
lib_name:
- dir_name:
Scilab string. The variable name of the library to (re)create.
- Force
Scilab string. The name of the directory to look for
.sci
-files.- verb
boolean value (default value is
%f
). Set it to%t
to force the sci-files recompilation.- Names
boolean values (default value is
%f
). Set it to%t
to get information.a vector of strings, the names of function to include in the library. By default all the sci-files are taken into account
Description
For each
.sci
file indir_name
(or only those specified by theNames
argument),genlib
executes aexec
and saves the functions to the corresponding.bin
file. The.sci
file must not contain anything but Scilab functions. If a.bin
file is newer than the associated.sci
file,genlib
does not translate and save the file.This default behaviour can be changed if
force
is given and set to%t
. In this latter case the recompilation is always performed for each.sci
file.When all
.sci
files have been processed,genlib
creates a library variable namedlib_name
and saves it in the filelib
indir_name
. If the Scilab variablelib_name
is not protected (see predef) this variable is updated.If
verbose
is et to%t
information are displayed during the build process.If
dir_name
argument is not given and iflib_name
Scilab variable exists and it is a library dir_name is taken equal to thelib_name
library path (update mode).Restrictions
Scilab tacitly assumes that file
foo.sci
defines at least a function namedfoo
. If subsidiary functions are included, they are made known to Scilab only after the functionfoo
had been referenced.
lib
library definition
Calling Sequence
namelib = lib('lib-dir')Arguments
lib-dir
- namelib
character string
library variable returned by 'lib'.
Description
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 callednames
, that contains the names of the functions defined inlib-dir
. On success, all functions inlib-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
. A library variable usually is saved for later loading, either on-line or from the user-specific startup file (see startup).value returned by 'lib' must be insert in a variable 'namelib' to access to macro functions of this library.
Restrictions
Scilab tacitly assumes that each xxxx.bin file defines a variable named
xxxx
.
Examples
//define some functions function z=myplus(x, y) z = x + y endfunction function z=yourplus(x, y) x = x - y endfunction //create the *.bin files in libdir libdir = TMPDIR; save(libdir + '/myplus.bin', myplus); save(libdir + '/yourplus.bin', yourplus); //create the name file mputl(['myplus';'yourplus'],TMPDIR+'/names'); //build the library containing myplus and yourplus mylibfoo = lib(libdir+'/'); //erase the variables clear myplus yourplus //Automatic loading and execution myplus(1,2) //erase the variables clear myplus yourplus mylibfoo [n,p] = libraryinfo('mylibfoo') isdef('myplus') clear mylibfoo isdef('myplus')
library
library datatype description
Calling Sequence
Description
A library is a data type with type number 14. It contains a path-name and a set of names. It allows automatic loading of variables using the following algorithm:
Suppose the Scilab user references the variable named
foo
. Scilab first looks iffoo
is the name of a primitive or of an already defined variable. If not, it looks forfoo
sequentially (the newest first) in all defined library .Suppose
foo
belongs to the set of names of the libraryxlib
then Scilab tries to load the file <xlib-path-name>/foo.bin. <xlib-path-name>/foo.bin must have been created using thesave
functionLibrary are often used for collection of functions, but they can also be used for any collection of scilab variables
If a function is defined in more than one library, the default search algorithm loads thode contained in the newest. It possible to force the use of a specific library using dot notation:
xlib.foo
loads the variablefoo
contained inxlib
. iffoo
is a function andxlib.foo(args)
executes the functionsExamples
// elemlib is a predefined library elementary_functionlib //displays the contents of the library A=rand(3,3); cosm(A) //loads cosm and executes it whos -name cosm // now cosm is a variable elementary_functionlib.sinm //loads sinm from the library elementary_functionlib.cosm(A) //reloads cosm and executes it