<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>STRUCTINSERT</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">STRUCTINSERT</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>
Inserts a key-value pair into a 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>
True, upon successful completion. If structure does not exist, or if key exists and allowoverwrite = &quot;False&quot;, 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>StructInsert(structure, key, value [, allowoverwrite ])
</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">History</span>
<p>
ColdFusion&#160;MX: Changed behavior: this function can be used on XML objects.
</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;h1&gt;Add New Employees&lt;/h1&gt;
&lt;!--- Establish params for first time through ---&gt;
&lt;cfparam name = &quot;FORM.firstname&quot; default = &quot;&quot;&gt;
&lt;cfparam name = &quot;FORM.lastname&quot; default = &quot;&quot;&gt;
&lt;cfparam name = &quot;FORM.email&quot; default = &quot;&quot;&gt;
&lt;cfparam name = &quot;FORM.phone&quot; default = &quot;&quot;&gt;
&lt;cfparam name = &quot;FORM.department&quot; default = &quot;&quot;&gt; 

&lt;cfif FORM.firstname EQ &quot;&quot;&gt;
 &lt;p&gt;Please fill out the form.
&lt;cfelse&gt;
 &lt;cfoutput&gt;
  &lt;CFScript&gt;
   employee = StructNew();
   StructInsert(employee, &quot;firstname&quot;, FORM.firstname);
   StructInsert(employee, &quot;lastname&quot;, FORM.lastname);
   StructInsert(employee, &quot;email&quot;, FORM.email);
   StructInsert(employee, &quot;phone&quot;, FORM.phone);
   StructInsert(employee, &quot;department&quot;, FORM.department);
 &lt;/CFScript&gt; 

 &lt;p&gt;First name is #StructFind(employee, &quot;firstname&quot;)#&lt;/p&gt;
 &lt;p&gt;Last name is #StructFind(employee, &quot;lastname&quot;)#&lt;/p&gt;
 &lt;p&gt;EMail is #StructFind(employee, &quot;email&quot;)#&lt;/p&gt;
 &lt;p&gt;Phone is #StructFind(employee, &quot;phone&quot;)#&lt;/p&gt;
 &lt;p&gt;Department is #StructFind(employee, &quot;department&quot;)#&lt;/p&gt;
 &lt;/cfoutput&gt;

 &lt;!--- Call the custom tag that adds employees ---&gt;
 &lt;CF_ADDEMPLOYEE EMPINFO = &quot;#employee#&quot;&gt;
&lt;/cfif&gt;

&lt;Hr&gt;
&lt;form action = &quot;structinsert.cfm&quot;&gt;
   &lt;p&gt;First Name:&amp;nbsp;
   &lt;input name = &quot;firstname&quot; type = &quot;text&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;
   &lt;p&gt;Last Name:&amp;nbsp;
   &lt;input name = &quot;lastname&quot; type = &quot;text&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;
   &lt;p&gt;EMail:&amp;nbsp;
   &lt;input name = &quot;email&quot; type = &quot;text&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;
   &lt;p&gt;Phone:&amp;nbsp;
   &lt;input name = &quot;phone&quot; type = &quot;text&quot; hspace = &quot;20&quot; maxlength = &quot;20&quot;&gt;
   &lt;p&gt;Department:&amp;nbsp;
   &lt;input name = &quot;department&quot; type = &quot;text&quot; hspace = &quot;30&quot; maxlength = &quot;30&quot;&gt;
   &lt;p&gt;
   &lt;input type = &quot;submit&quot; value = &quot;OK&quot;&gt;
&lt;/form&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 to contain the new key-value pair.</p>

  </td>
  </tr>
  </table>
</div>
<div id="KEY">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">KEY</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>Key that contains the inserted value.</p>

  </td>
  </tr>
  </table>
</div>
<div id="VALUE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">VALUE</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>Value to add.</p>

  </td>
  </tr>
  </table>
</div>
<div id="ALLOWOVERWRITE">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ALLOWOVERWRITE</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>Optional. Whether to allow overwriting a key. The default value is False.</p>

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

  </body>
</html>
