add more help pages related to CAPI - check parameters - optional parameters
[scilab.git] / scilab / modules / core / help / en_US / capi / NumOpt.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry version="5.0-subset Scilab" xml:id="NumOpt" xml:lang="en"
3           xmlns="http://docbook.org/ns/docbook"
4           xmlns:xlink="http://www.w3.org/1999/xlink"
5           xmlns:svg="http://www.w3.org/2000/svg"
6           xmlns:mml="http://www.w3.org/1998/Math/MathML"
7           xmlns:html="http://www.w3.org/1999/xhtml"
8           xmlns:db="http://docbook.org/ns/docbook">
9   <refnamediv>
10     <refname>NumOpt</refname>
11
12     <refpurpose>C interface function which returns the number of optional
13     parameters sent to a C function</refpurpose>
14   </refnamediv>
15
16   <refsynopsisdiv>
17     <title>Calling Sequence</title>
18
19     <synopsis>Res = NumOpt()</synopsis>
20   </refsynopsisdiv>
21
22   <refsection>
23     <title>Parameters</title>
24
25     <variablelist>
26       <varlistentry>
27         <term>Res</term>
28
29         <listitem>
30           <para>the number of optional parameters detected</para>
31         </listitem>
32       </varlistentry>
33     </variablelist>
34   </refsection>
35
36   <refsection>
37     <title>Description</title>
38
39     <para>C interface function which returns the number of optional parameters
40     sent to a C function. You must include stack-c.h to benefit from this
41     function.</para>
42   </refsection>
43
44   <refsection>
45     <title>Examples</title>
46
47     <para>A more complete example is available in the directory
48     example/optional_parameters.</para>
49
50     <programlisting role="example"> 
51 #include &lt;stack-c.h&gt;
52
53 int sci_optional_parameters(char * fname)
54
55   int m1,n1,l1;
56
57   // optional names must be stored in alphabetical order in opts
58   static rhs_opts opts[]= {{-1,"v1","d",0,0,0},
59                            {-1,"v2","d",0,0,0},
60                            {-1,NULL,NULL,0,0}};
61
62   int minrhs = 1, maxrhs = 1;
63   int minlhs = 1, maxlhs = 3;
64   int nopt, iopos, res;
65   char buffer_name[csiz]; // csiz used for character coding
66
67   nopt = NumOpt();
68
69   CheckRhs(minrhs,maxrhs+nopt);
70   CheckLhs(minlhs,maxlhs);
71
72   // first non optional argument
73   GetRhsVar( 1, "c", &amp;m1, &amp;n1, &amp;l1);
74   
75   if (get_optionals(fname,opts)==0) return 0;
76
77   sciprint("number of optional parameters = %d\n", NumOpt());
78   sciprint("first optional parameters = %d\n", FirstOpt());
79   sciprint("FindOpt(v1) = %d\n", FindOpt("v1", opts));
80   sciprint("FindOpt(v2) = %d\n", FindOpt("v2", opts));
81
82   if (IsOpt(1,buffer_name))
83     sciprint("parameter 1 is optional: %s\n", buffer_name);
84   if (IsOpt(2,buffer_name))
85     sciprint("parameter 2 is optional: %s\n", buffer_name);
86   if (IsOpt(3,buffer_name))
87     sciprint("parameter 3 is optional: %s\n", buffer_name);
88
89   return 0;
90 }
91  </programlisting>
92   </refsection>
93
94   <refsection>
95     <title>See Also</title>
96
97     <simplelist type="inline">
98       <member><link linkend="CheckDims">CheckDims</link></member>
99
100       <member><link linkend="CheckRow">CheckRow</link></member>
101
102       <member><link linkend="CheckScalar">CheckScalar</link></member>
103
104       <member><link linkend="CheckVector">CheckVector</link></member>
105
106       <member><link linkend="OverLoad">CheckOverLoad</link></member>
107
108       <member><link linkend="CheckDimProp">CheckDimProp</link></member>
109
110       <member><link linkend="CheckLength">CheckLength</link></member>
111
112       <member><link linkend="CheckSameDims">CheckSameDims</link></member>
113
114       <member><link linkend="CheckSquare">CheckSquare</link></member>
115
116       <member><link
117       linkend="How to check parameters">HowToCheckParameters</link></member>
118     </simplelist>
119   </refsection>
120 </refentry>