<?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:ns5="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="mfprintf" xml:lang="en">
    <refnamediv>
        <refname>mfprintf</refname>
        <refpurpose>converts, formats, and writes data to a file</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>mfprintf(fd, format, a1, ..., an);</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>fd</term>
                <listitem>
                    <para>
                        a scalar, file descriptor given by <function>mopen</function>
                        (it's a positive integer).
                    </para>
                    <para>
                        If <varname>fd</varname> equals 0 redirection in stderr.
                    </para>
                    <para>
                        If <varname>fd</varname> equals 6 redirection in stdout.
                    </para>
                    <para>
                        OBSOLETE: The value <literal>-1</literal> refers to the
                        default file (i.e the last opened file).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>format</term>
                <listitem>
                    <para>
                        a Scilab string describing the format to use to write the
                        remaining operands. The
                        <varname>
                            format
                        </varname>
                        operand follows,
                        as close as possible, the C
                        <function>
                            printf
                        </function>
                        format
                        operand syntax.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>str</term>
                <listitem>
                    <para>a character string: a string to be scanned.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>a1, ..., an</term>
                <listitem>
                    <para>
                        the data to be converted and printed according to
                        the format parameter.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            The <function>mfprintf</function> function is a interface for C-coded
            version of <function>fprintf</function> function.
        </para>
        <para>
            The <function>mfprintf</function> function writes formatted operands
            to the file specified by the file descriptor <varname>fd</varname>. The
            argument operands are formatted under control of the
            <varname>format</varname> operand.
        </para>
        <para>
            This function may be used to output column vectors of numbers
            and string vectors without an explicit loop on the elements. In that
            case this function iterates on the rows. The shortest vector gives the
            number of time the format has to be iterated.
        </para>
        <para>
            An homogeneous sequence of identical type parameters can be replaced
            by a matrix.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[

fd = mopen(TMPDIR+'/text.txt','wt');
mfprintf(fd,'hello %s %d.\n','world',1);
mfprintf(fd,'hello %s %d.\n','scilab',2);
mfprintf(fd,'This line is built with a column vector (26:28) %d.\n',[26:28].');
mfprintf(fd,'This line is built with a row vector (26:28) %d.\n',[26:28]);
A = rand(3,6);
mfprintf(fd,'This line is built with a matrix %.3f.\n',A);
mclose(fd);
if (isdef('editor') | (funptr('editor')<>0)) then
  editor(TMPDIR+'/text.txt')
end
mfprintf(0,'stderr output.\n');
mfprintf(6,'stdout output.\n');
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="mclose">mclose</link>
            </member>
            <member>
                <link linkend="meof">meof</link>
            </member>
            <member>
                <link linkend="fprintfMat">fprintfMat</link>
            </member>
            <member>
                <link linkend="mfscanf">mfscanf</link>
            </member>
            <member>
                <link linkend="fscanfMat">fscanfMat</link>
            </member>
            <member>
                <link linkend="mget">mget</link>
            </member>
            <member>
                <link linkend="mgetstr">mgetstr</link>
            </member>
            <member>
                <link linkend="mopen">mopen</link>
            </member>
            <member>
                <link linkend="mprintf">mprintf</link>
            </member>
            <member>
                <link linkend="mput">mput</link>
            </member>
            <member>
                <link linkend="mputstr">mputstr</link>
            </member>
            <member>
                <link linkend="mseek">mseek</link>
            </member>
            <member>
                <link linkend="mtell">mtell</link>
            </member>
            <member>
                <link linkend="mdelete">mdelete</link>
            </member>
            <member>
                <link linkend="printf_conversion">printf_conversion</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
