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