User Guide

Table Of Contents
116 Chapter 5: Using Arrays and Structures
Structure reference
<cfdump var=#structRef#><br>
<br>
Change a string, array element, and structure value in the reference<br>
<br>
<cfset structRef.key1="1C">
<cfset structRef.key3[2]="4C">
<cfset structRef.key4.Struct2key2="6C">
Original structure<br>
<cfdump var=#myNewStructure#><br>
Copied structure<br>
<cfdump var=#CopiedStruct#><br>
Duplicated structure<br>
<cfdump var=#DupStruct#><br>
Structure reference
<cfdump var=#structRef#><br>
<br>
Clear the original structure<br>
<cfset foo=structclear(myNewStructure)>
Original structure:<br>
<cfdump var=#myNewStructure#><br>
Copied structure<br>
<cfdump var=#CopiedStruct#><br>
Duplicated structure<br>
<cfdump var=#DupStruct#><br>
Structure reference:<br>
<cfdump var=#structRef#><br>
Deleting structure elements and structures
To delete a key and its value from a structure, use the
StructDelete function, as follows:
StructDelete(structure_name, key [, indicateNotExisting ])
The indicateNotExisting argument tells the function what to do if the specified key does not exist.
By default, the function always returns True. However, if you specify True for the
indicateNotExisting argument, the function returns True if the key exists and False if it does not.
You can also use the
StructClear function to delete all the data in a structure but keep the
structure instance itself, as follows:
StructClear(structure_name)
If you use StructClear to delete a structure that you have copied using the StructCopy
function, the specified structure is deleted, but the copy is unaffected.
If you use
StructClear to delete a structure that has a multiple references, the function deletes
the contents of the structure and all references point to the empty structure, as shown in the
following example:
<cfset myStruct.Key1="Macromedia">
Structure before StructClear<br>
<cfdump var="#myStruct#">
<cfset myCopy=myStruct>
<cfset StructClear(myCopy)>
After Clear:<br>