<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 * Copyright (C) 2009 - DIGITEO - Allan CORNET
 *
 * 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:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="merror" xml:lang="en">
    <refnamediv>
        <refname>merror</refname>
        <refpurpose>tests the file access errors indicator</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            err = merror([fd])
            [err, msg] = merror([fd])
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>fd</term>
                <listitem>
                    <para>
                        a scalar: the <varname>fd</varname> parameter returned by the
                        function <function>mopen</function> is used as a file descriptor
                        (it's a positive integer). -1 stands for last opened file. The
                        default value is -1.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>err</term>
                <listitem>
                    <para>a scalar: an error status number of the most
                        recent file I/O operation associated with the specified file.
                    </para>
                    <para>
                        If the most recent I/O operation performed on the specified
                        file was successful, the value of <varname>msg</varname> is empty
                        and <function>merror</function> returns an <varname>err</varname>
                        value of 0.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>msg</term>
                <listitem>
                    <para>a string: an error string message.</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            The function <function>merror</function> is used to test the file
            access errors indicator returning non-zero if it is set. The error
            indicator can only be reset by the <function>mclearerr</function>
            function.
        </para>
        <para>
            A nonzero <varname>err</varname> indicates that an error occurred in the most recent file I/O operation. The value of message is a string that can contain information about the nature of the error. If the message is not helpful, consult the C run-time library manual for your host operating system for further details.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
fd = mopen(TMPDIR +'/filetxt.txt','wt');
[err,msg] = merror(fd)
if (err <> 0) then
  mprintf('Problem\n');
end
mclose(fd);
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="mclearerr">mclearerr</link>
            </member>
            <member>
                <link linkend="mclose">mclose</link>
            </member>
            <member>
                <link linkend="mopen">mopen</link>
            </member>
            <member>
                <link linkend="mput">mput</link>
            </member>
            <member>
                <link linkend="mget">mget</link>
            </member>
            <member>
                <link linkend="mgetstr">mgetstr</link>
            </member>
            <member>
                <link linkend="mputstr">mputstr</link>
            </member>
            <member>
                <link linkend="meof">meof</link>
            </member>
            <member>
                <link linkend="mseek">mseek</link>
            </member>
            <member>
                <link linkend="mtell">mtell</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
