<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) ????-2008 - INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="library">
    <refnamediv>
        <refname>library</refname>
        <refpurpose>library datatype description
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>

    </refsynopsisdiv>
    <refsection>
        <title>Description</title>
        <para>
            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:
        </para>
        <para>
            Suppose the Scilab user references the variable named <literal>foo</literal>.
            Scilab first looks if <literal>foo</literal> is the name of a primitive or of an
            already defined variable. If not, it looks for <literal>foo</literal> sequentially
            (the newest first) in all defined library .
        </para>
        <para>
            Suppose <literal>foo</literal> belongs to the set of names of the library <literal>xlib</literal>
            then Scilab tries to load the file
            &lt;xlib-path-name&gt;/foo.bin. &lt;xlib-path-name&gt;/foo.bin must have been
            created using the <literal>save</literal> function
        </para>
        <para>
            Library are often used for collection of functions, but they can also
            be used for any collection of scilab variables
        </para>
        <para>
            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:
        </para>
        <para>
            <literal>xlib.foo</literal> loads the variable <literal>foo</literal> contained in <literal>xlib</literal>.
            if <literal>foo</literal> is a function
            and <literal>xlib.foo(args)</literal> executes the functions
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
// 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
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="lib">lib</link>
            </member>
            <member>
                <link linkend="string">string</link>
            </member>
            <member>
                <link linkend="load">load</link>
            </member>
            <member>
                <link linkend="save">save</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
