3.2.2 Loading Functions

Functions are usually defined in files. A file which contains a function must obey the following format
function [y1,...,yn]=foo(x1,...,xm)
   .
   .
   .
where foo is the function name. The xi's are the input parameters and the the yj's are the output parameters, and the three vertical dots represent the set of instructions performed by the function to evaluate the yj's, given the xi's. Inputs and ouputs parameters can be any Scilab object (including functions themeselves).

Functions are Scilab objects and should not be considered as files. To be used in Scilab, functions defined in files must be loaded by the command getf(filename) or exec(filename,-1) ; . If the file filename contains the function foo, the function foo can be executed only if it has been previously loaded by the command getf(filename). A file may contain several functions. Functions can also be defined ``on line'' by the command using the function/endfunction syntax or by using the function deff. This is useful if one wants to define a function as the output parameter of a other function.

Collections of functions can be organized as libraries (see lib command). Standard Scilab librairies (linear algebra, control,...) are defined in the subdirectories of SCIDIR/macros/.