License Header change: Removed the LICENSE_END before beta
[scilab.git] / scilab / modules / api_scilab / help / ja_JP / legacy / list_management / list_getlistitemaddress_api.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2009  - DIGITEO - Antoine ELIAS
5  * 
6  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
8  * This file is hereby licensed under the terms of the GNU GPL v2.0,
9  * pursuant to article 5.3.4 of the CeCILL v.2.1.
10  * This file was originally licensed under the terms of the CeCILL v2.1,
11  * and continues to be available under such terms.
12  * For more information, see the COPYING file which you should have received
13  * along with this program.
14  *
15  -->
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="list_getlistitemaddress_API" xml:lang="ja">
17     <refnamediv>
18         <refname>子要素を取得 (Scilab ゲートウェイ)</refname>
19         <refpurpose>
20             子要素のアドレスを取得する方法.
21         </refpurpose>
22     </refnamediv>
23     <refsynopsisdiv>
24         <title>呼び出し手順</title>
25         <synopsis>SciErr getListItemAddress(void* _pvCtx, int* _piAddress, int _iItemNum, int** _piItemAddress)</synopsis>
26     </refsynopsisdiv>
27     <refsection>
28         <title>引数</title>
29         <variablelist>
30             <varlistentry>
31                 <term>_pvCtx</term>
32                 <listitem>
33                     <para>
34                         Scilab環境ポインタ, api_scilab.hで定義された"pvApiCtx"で指定.
35                     </para>
36                 </listitem>
37             </varlistentry>
38             <varlistentry>
39                 <term>_piAddress</term>
40                 <listitem>
41                     <para>
42                         リストのアドレス.
43                     </para>
44                 </listitem>
45             </varlistentry>
46             <varlistentry>
47                 <term>_iItemNum</term>
48                 <listitem>
49                     <para>
50                         要素番号.
51                     </para>
52                 </listitem>
53             </varlistentry>
54             <varlistentry>
55                 <term>_piItemAddress</term>
56                 <listitem>
57                     <para>
58                         要素が返されるアドレス.
59                     </para>
60                 </listitem>
61             </varlistentry>
62             <varlistentry>
63                 <term>SciErr</term>
64                 <listitem>
65                     <para>
66                         エラーメッセージの履歴と最初のエラー番号が保存されるエラー構造体.
67                     </para>
68                 </listitem>
69             </varlistentry>
70         </variablelist>
71     </refsection>
72     <refsection>
73         <title>説明</title>
74         <para>このヘルプは子要素のアドレスを取得する方法を記述します.</para>
75     </refsection>
76     <refsection>
77         <!--File_gateway: SCI/modules/api_scilab/tests/unit_tests/common_list_api.c-->
78         <!--File_scilab: SCI/modules/api_scilab/tests/unit_tests/common_list_api.tst-->
79         <!--Lib_name: common_list-->
80         <!--Func_list: common_list-->
81         <title>ゲートウェイのソース</title>
82         <programlisting role="code_gateway"><![CDATA[ 
83 #include "api_scilab.h"
84 int get_list_info(int* _piAddress);
85 void insert_indent(void);
86 static int iLocalTab = 0;
87 int common_list(char *fname,void* pvApiCtx)
88 {
89     SciErr sciErr;
90     int *piAddr = NULL;
91     CheckInputArgument(pvApiCtx, 1, 1);
92     sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
93     if(sciErr.iErr)
94     {
95         printError(&sciErr, 0);
96         return 0;
97     }
98     get_list_info(piAddr);
99     AssignOutputVariable(pvApiCtx, 1) = 0;
100     return 0;
101 }
102 int get_list_info(int* _piAddress)
103 {
104     SciErr sciErr;
105     int i       = 0;
106     int iRet    = 0;
107     int iItem   = 0;
108     //get list item number, failed if variable is not a kind of list
109     sciErr = getListItemNumber(pvApiCtx, _piAddress, &iItem);
110     if(sciErr.iErr)
111     {
112         printError(&sciErr, 0);
113         sciprint("This variable is not a list");
114         return 0;
115     }
116     sciprint("List (%d items) -> address : 0x%08X) : \n", iItem, _piAddress);
117     for(i = 0 ; i < iItem ; i++)
118     {
119         int iType           = 0;
120         int* piAddrChild    = NULL;
121         sciErr = getListItemAddress(pvApiCtx, _piAddress, i + 1, &piAddrChild);
122         if(sciErr.iErr)
123         {
124             printError(&sciErr, 0);
125             return 0;
126         }
127         sciErr = getVarType(pvApiCtx, piAddrChild, &iType);
128         if(sciErr.iErr)
129         {
130             printError(&sciErr, 0);
131             return 0;
132         }
133         if(iType == sci_list || iType == sci_tlist || iType == sci_mlist)
134         {
135             insert_indent();
136             sciprint("Child %d -> ", i + 1);
137             iLocalTab++;
138             iRet = get_list_info(piAddrChild);
139             iLocalTab--;
140             if(iRet)
141             {
142                 return 1;
143             }
144         }
145         else
146         {
147             insert_indent();
148             sciprint("Child %d -> address : 0x%08X\n", i + 1, piAddrChild);
149         }
150     }
151     return 0;
152 }
153 void insert_indent(void)
154 {
155     int i = 0;
156     for(i = 0 ; i < iLocalTab ; i++)
157     {
158         sciprint("\t");
159     }
160 }
161  ]]></programlisting>
162     </refsection>
163     <refsection>
164         <title>Scilabテストスクリプト</title>
165         <programlisting role="code_scilab"><![CDATA[ 
166 l1 = [1,2*%i,3;%i,2,3*%i];
167 l2 = ["may","the";"puffin","be";"with","you"];
168 l3 = int8([1,2,3]);
169 l5 = list(l1,l2,l3);
170 l4 = list(l5, list(l5,l5));
171 l6 = uint16([1000,2000,3000]);
172 l = list(l1,l2,l3,l6,l4,l5);
173 common_list(l)
174  ]]></programlisting>
175     </refsection>
176 </refentry>