* Bug #13175 fixed - Update argn() help page.
[scilab.git] / scilab / modules / functions / help / en_US / argn.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <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="argn">
3     <refnamediv>
4         <refname>argn</refname>
5         <refpurpose>Returns the number of input/output arguments in a function call</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>Calling Sequence</title>
9         <synopsis>[lhs [,rhs] ]=argn()
10             lhs=argn(1)
11             rhs=argn(2)
12         </synopsis>
13     </refsynopsisdiv>
14     <refsection>
15         <title>Description</title>
16         <para>
17             This function is used inside a function definition.
18             It gives the number of actual inputs arguments (<varname>rhs</varname>)
19             and output arguments (<varname>lhs</varname>) passed to the function when the function is 
20             called. It is usually used in function definitions to deal with 
21             optional arguments.
22         </para>
23         <para>
24             Note that <varname>lhs</varname> is always greater than or equal to 1. That is to say, even if a function
25             is called without having mentioned an output argument, <varname>lhs</varname> will be equal to 1.
26         </para>
27     </refsection>
28     <refsection>
29         <title>Examples</title>
30         <programlisting role="example"><![CDATA[ 
31 function concat=myOwnFunction(name,optional)
32   [lhs,rhs]=argn(0);
33   disp(lhs);
34   if rhs <= 1 then
35          optional="my Optional value";
36   end
37   if rhs == 0 then
38          error("Expect at least one argument");
39   end
40   concat=name+" "+optional;
41 endfunction
42  ]]></programlisting>
43     </refsection>
44     <refsection role="see also">
45         <title>See Also</title>
46         <simplelist type="inline">
47             <member>
48                 <link linkend="function">function</link>
49             </member>
50             <member>
51                 <link linkend="varargin">varargin</link>
52             </member>
53         </simplelist>
54     </refsection>
55 </refentry>