<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>STRUCTKEYARRAY</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">STRUCTKEYARRAY</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Finds the keys in a ColdFusion structure.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
An array of keys; if structure does not exist, ColdFusion throws an exception.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
Structure functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>StructKeyArray(structure)
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
Structure functions; "Modifying a ColdFusion XML object" in Chapter&#160;35, "Using XML and WDDX," in ColdFusion MX Developer's Guide
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
A structure's keys are unordered.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span><pre>&lt;!--- Shows StructKeyArray function to copy keys from a structure to an array. 
Uses StructNew to create structure and fills its fields with the
information the user enters in the form fields. ---&gt;
&lt;h3&gt;StructKeyArray Example&lt;/h3&gt;
&lt;h3&gt;Extracting the Keys from the Employee Structure&lt;/h3&gt;    
&lt;!-- Create structure. Check whether Submit was pressed. If so, define fields 
in employee structure with user entries on form. -----&gt;
&lt;cfset employee = StructNew()&gt; 
&lt;cfif Isdefined(&quot;Form.Submit&quot;)&gt;
   &lt;cfif Form.Submit is &quot;OK&quot;&gt;
      &lt;cfset employee.firstname = FORM.firstname&gt;
      &lt;cfset employee.lastname = FORM.lastname&gt;
      &lt;cfset employee.email = FORM.email&gt;
      &lt;cfset employee.phone = FORM.phone&gt;
      &lt;cfset employee.company = FORM.company&gt; 
   &lt;cfelseIf Form.Submit is &quot;Clear&quot;&gt;
      &lt;cfset rc = StructClear(employee)&gt;
   &lt;/cfif&gt;
&lt;/cfif&gt;    
&lt;p&gt; This example uses the StructNew function to create a structure called
&quot;employee&quot; that supplies employee info. Its fields are filled by 
the form. After you enter employee information in structure, the 
example uses StructKeyArray function to copy all of the keys from 
the structure into an array. &lt;/p&gt;
&lt;hr size = &quot;2&quot; color = &quot;#0000A0&quot;&gt;
&lt;form action = &quot;structkeyarray.cfm&quot;&gt;
&lt;table cellspacing = &quot;2&quot; cellpadding = &quot;2&quot; border = &quot;0&quot;&gt;
   &lt;tr&gt;
   &lt;td&gt;First Name:&lt;/td&gt;
   &lt;td&gt;&lt;input name = &quot;firstname&quot; type = &quot;text&quot; 
      value = &quot;&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;Last Name:&lt;/td&gt;
   &lt;td&gt;&lt;input name = &quot;lastname&quot; type = &quot;text&quot; 
      value = &quot;&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;EMail&lt;/td&gt;
   &lt;td&gt;&lt;input name = &quot;email&quot; type = &quot;text&quot; 
      value = &quot;&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;Phone:&lt;/td&gt;
   &lt;td&gt;&lt;input name = &quot;phone&quot; type = &quot;text&quot; 
      value = &quot;&quot; hspace = &quot;20&quot; maxlength = &quot;20&quot;&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;Company:&lt;/td&gt;
   &lt;td&gt;&lt;input name = &quot;company&quot; type = &quot;text&quot; 
      value = &quot;&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;&lt;input type = &quot;submit&quot; name = &quot;submit&quot; 
      value = &quot;OK&quot;&gt;&lt;/td&gt;
   &lt;td&gt;&lt;b&gt;After you submit the FORM, scroll down to see the array.&lt;/b&gt;
   &lt;/td&gt;
   &lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;cfif NOT StructISEmpty(employee)&gt; 
   &lt;hr size = &quot;2&quot; color = &quot;#0000A0&quot;&gt;
   &lt;cfset keysToStruct = StructKeyArray(employee)&gt;
   &lt;cfloop index = &quot;i&quot; from = &quot;1&quot; to = &quot;#ArrayLen(keysToStruct)#&quot;&gt;
      &lt;p&gt;&lt;cfoutput&gt;Key#i# is #keysToStruct[i]#&lt;/cfoutput&gt;&lt;/p&gt;
      &lt;p&gt;&lt;cfoutput&gt;Value#i# is #employee[keysToStruct[i]]#&lt;/cfoutput&gt;
      &lt;/p&gt;
   &lt;/cfloop&gt;
&lt;/cfif&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="STRUCTURE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">STRUCTURE</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>Structure from which to extract a list of keys</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
