<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) ENPC - Jean-Philippe Chancelier
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 * Copyright (C) 2020 - Samuel GOUGEON
 *
 * 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="xsave">
    <refnamediv>
        <refname>xsave</refname>
        <refpurpose>save graphics into a
            file
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            xsave(filename)
            xsave(filename, win_num)
            xsave(filename, win_handle)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>file_name</term>
                <listitem>
                    string, name of the file.
                    <para/>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>win_num</term>
                <listitem>
                    integer: the graphics window number. If not given, the current
                        graphics window is considered.
                    <para/>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>win_handle</term>
                <listitem>
                    handle of the figure to save. By default, gcf() is used.
                    <para/>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <literal>xsave</literal> saves the graphics contained in the graphics window
            <literal>win_num</literal> in the binary file <literal>file_name</literal>, and can be
            reloaded with <literal>xload</literal>.
        </para>
        <note>
            <literal>xsave(file_name, win_num)</literal> and
            <literal>xsave(file_name, win_handle)</literal> are just shortcuts respectively for
            <literal>h=findobj("figure_id", win_num); save(file_name, "h")</literal> and
            <literal>save(file_name, "win_handle")</literal>, that can be used directly.
        </note>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
t = 0:0.01:10;
subplot(211), plot2d(t,sin(t))
subplot(212), plot2d(t,sin(3*t))
xsave(TMPDIR + "/foo.scg", gcf())
clf()
xload(TMPDIR + "/foo.scg")

a = gca();
curve = a.children.children; // handle on the curve
save(TMPDIR + "/foo.scg", "curve")
delete(curve)
load(TMPDIR + "/foo.scg")
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="xload">xload</link>
            </member>
            <member>
                <link linkend="save">save</link>
            </member>
            <member>
                <link linkend="load">load</link>
            </member>
        </simplelist>
    </refsection>

    <refsection role="history">
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.0</revnumber>
                <revdescription>
                    All <link linkend="uimenu">uimenu</link> and <link linkend="uicontrol">uicontrol</link>
                    elements of the figure are now saved as well.
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
