<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) XXXX-2008 - INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 * Copyright (C) 2020 - Stephane MOTTELET
 *
 * 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="get_absolute_file_path" xml:lang="en">
    <refnamediv>
        <refname>get_absolute_file_path</refname>
        <refpurpose>
            gives an absolute pathname of a file opened in Scilab
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>[filepath, filename] = get_absolute_file_path()</synopsis>
        <synopsis>filepath = get_absolute_file_path(filename)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>filename</term>
                <listitem>
                    <para>a character string: name of the file.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>filepath</term>
                <listitem>
                    <para>a character string: an absolute path.</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <function>get_absolute_file_path(filename)</function> searches in Scilab's
            internal list of currently opened files the file with name <varname>filename</varname>
            and returns its path <varname>pathname</varname>.
        </para>
       <para>If file is not opened, it will return an error.</para>
      <para>Without input arguments and called from a script, <function>get_absolute_file_path()</function>
        returns the absolute path of the script and optionally its name. When called without input arguments
        from the command line <function>get_absolute_file_path()</function> returns an error.
      </para>
        <para>
            <warning>
                In previous version (Scilab 5.0.x) current directory was
                returned if file was not found.
            </warning>
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
mputl(['[filepath,filename]=get_absolute_file_path()'
       'disp(filepath,filename)'],TMPDIR+'/script.sce');
exec(TMPDIR+'/script.sce',-1)
 ]]></programlisting>
        <programlisting role="example"><![CDATA[
fd = mopen(TMPDIR+'/foo.txt','wt');
filepath = get_absolute_file_path("foo.txt")
mclose(fd)
filepath = get_absolute_file_path("foo.txt")
]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="dispfiles">dispfiles</link>
            </member>
            <member>
                <link linkend="file">file(id)</link>
            </member>
            <member>
                <link linkend="getshortpathname">getshortpathname</link>
            </member>
            <member>
                <link linkend="getlongpathname">getlongpathname</link>
            </member>
            <member>
                <link linkend="pwd">pwd</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
