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