<?xml version="1.0" encoding="UTF-8"?>
<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="where">
    <refnamediv>
        <refname>where</refname>
        <refpurpose>get current instruction calling tree</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>[linenum, callername] = where()</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>linenum</term>
                <listitem>
                    <para>a column vector of integers</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>callername</term>
                <listitem>
                    <para>a column vector of strings</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <code>[linenum, callername] = where()</code> returns <varname>linenum</varname> and
            <varname>callername</varname> such as current instruction has been
            called by the <code>linenum(1)</code> line of function
            <code>callername(1)</code>, <code>callername(1)</code> has been called by the
            <code>linenum(2)</code> line of function <code>callername(2)</code>
            and so on.
        </para>
        <para>
            <code>callername(i)</code> is in general the name of a function but it may also be
            <literal>"exec"</literal> or <literal>"execstr"</literal> if instruction lies in an
            exec file or an execstr instruction.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
function foo()
    c = 1
    [a,b] = where()
    disp("Line:")
    disp(a);
    disp("Function:")
    disp(b);
endfunction

function test()
    function beer()
        foo()
    endfunction
    beer()
endfunction

test()
 ]]></programlisting>
    <screen><![CDATA[
--> test()
 Line:
   3.
   2.
   5.

 Function:
!foo   !
!beer  !
!test  !
]]></screen>
    </refsection>

    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="whereami">whereami</link>
            </member>
            <member>
                <link linkend="recursionlimit">recursionlimit</link>
            </member>
            <member>
                <link linkend="pause">pause</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
