| STRUCTKEYARRAY | |
| 説明
構造体内のキーを取り出します。 |
|
| 戻り値
キーの配列。structure が存在しない場合は例外が発生します。 |
|
| カテゴリ
構造体関数 |
|
関数のシンタックスStructKeyArray(structure) |
|
| 関連項目
構造体関数、『ColdFusion MX 開発ガイド』の第35章の「XML および WDDX の使用」 の「ColdFusion XML オブジェクトの変更」 |
|
| パラメータ
|
|
| 使用方法
構造体のキーはソートされていません。 |
|
例<!--- この例は、StructKeyArray 関数を使用して、構造体から配列にキーをコピーする方法を示しています。
StructNew 関数を使用して構造体を作成し、フォームフィールドに入力された情報をその構造体のフィールドに格
納します。 --->
<h3>StructKeyArray の例</h3>
<h3>Employee 構造体からのキー取り出し</h3>
<!-- 構造体を作成します。[送信] が押されたかどうかを確認します。押された場合は、フォームに入力された情報
を使用して、employee 構造体のフィールドを定義します。 ----->
<cfset employee = StructNew()>
<cfif Isdefined("Form.Submit")>
<cfif Form.Submit is "OK">
<cfset employee.firstname = FORM.firstname>
<cfset employee.lastname = FORM.lastname>
<cfset employee.email = FORM.email>
<cfset employee.phone = FORM.phone>
<cfset employee.company = FORM.company>
<cfelseIf Form.Submit is "Clear">
<cfset rc = StructClear(employee)>
</cfif>
</cfif>
<p> この例では、StructNew 関数を使用して、"employee" という名前の構造体を作成します。これは、従業員情
報を格納するための構造体です。構造体の各フィールドに格納する情報はフォームで入力します。従業員情報を構
造体に格納したら、StructKeyArray 関数を使用して、構造体のすべてのキーを配列にコピーします。</p>
<hr size = "2" color = "#0000A0">
<form action = "structkeyarray.cfm">
<table cellspacing = "2" cellpadding = "2" border = "0">
<tr>
<td>名前 :</td>
<td><input name = "firstname" type = "text"
value = "" hspace = "30" maxlength = "30"></td>
</tr>
<tr>
<td>姓 :</td>
<td><input name = "lastname" type = "text"
value = "" hspace = "30" maxlength = "30"></td>
</tr>
<tr>
<td>電子メール :</td>
<td><input name = "email" type = "text"
value = "" hspace = "30" maxlength = "30"></td>
</tr>
<tr>
<td>電話番号 :</td>
<td><input name = "phone" type = "text"
value = "" hspace = "20" maxlength = "20"></td>
</tr>
<tr>
<td>会社名 :</td>
<td><input name = "company" type = "text"
value = "" hspace = "30" maxlength = "30"></td>
</tr>
<tr>
<td><input type = "submit" name = "submit"
value = "送信"></td>
<td><b>フォームの送信後、下方向にスクロールすると配列が表示されます。</b>
</td>
</tr>
</table>
</form>
<cfif NOT StructISEmpty(employee)>
<hr size = "2" color = "#0000A0">
<cfset keysToStruct = StructKeyArray(employee)>
<cfloop index = "i" from = "1" to = "#ArrayLen(keysToStruct)#">
<p><cfoutput>Key#i# は #keysToStruct[i]#</cfoutput> です。</p>
<p><cfoutput>Value#i# は #employee[keysToStruct[i]]#</cfoutput> です。
</p>
</cfloop>
</cfif>
|
|
| STRUCTURE | |
| 構造体です。この中にあるキーのリストを取り出します。 | |