1 <?xml version="1.0" encoding="UTF-8"?>
3 <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:html="http://www.w3.org/1999/xhtml" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="getOptionals" xml:lang="ja">
7 <refname>オプション引数を取得 (Scilabゲートウェイ)</refname>
15 <synopsis>int getOptionals(void* _pvCtx, char* fname, rhs_opts opts[])</synopsis>
33 Scilab環境ポインタ, api_scilab.h により定義された "pvApiCtx"で指定.
63 <para>オプション引数の構造体配列</para>
79 オプション引数を使用するCゲートウェイ関数.
99 <programlisting role="example">
102 #include "api_scilab.h"
103 #include "sciprint.h"
104 #include "sciprint.h"
105 #include "sciprint.h"
107 int sci_use_optional(char * fname)
111 char* pstName = NULL;
115 static rhs_opts opts[] =
117 { -1, "age", -1, 0, 0, NULL},
118 { -1, "drivinglicense", -1, 0, 0, NULL},
119 { -1, "name", -1, 0, 0, NULL},
120 { -1, NULL, -1, 0, 0, NULL}
125 CheckInputArgument(pvApiCtx, 0, nopt);
126 CheckOutputArgument(pvApiCtx, 0, 1);
128 if (getOptionals(pvApiCtx, fname, opts) == 0)
134 if (opts[0].iPos != -1)
137 getScalarDouble(pvApiCtx, opts[0].piAddr, &dblAge);
145 if (opts[1].iPos != -1)
147 getScalarBoolean(pvApiCtx, opts[1].piAddr, &iDL);
154 if (opts[2].iPos != -1)
156 getAllocatedSingleString(pvApiCtx, opts[2].piAddr, &pstName);
160 pstName = strdup("John Doe");
166 sciprint("Read information: \n");
167 sciprint("\tName: \t\t\t%s\n", pstName);
168 sciprint("\tAge: \t\t\t%d\n", iAge);
169 sciprint("\tDriving licence: \t%s\n", iDL ? "Yes" : "No");
171 AssignOutputVariable(pvApiCtx, 0) = 1;
182 <title>Scilab テストスクリプト</title>
184 <programlisting role="code_scilab">
188 use_optional(name = "M. Puffin");
189 use_optional(age = 25, name = "M. Puffin");
190 use_optional(drivinglicense = %t, age = 25, name = "M. Puffin");
203 <revnumber>5.5.0</revnumber>
205 <revremark>この関数は Scilab 5.5.0で追加されました</revremark>