Adobe COLDFUSION 9 Manual page 106

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
<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(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
as follows:
StructClear(structure_name)
If you use
to delete a structure that you have copied using the
StructClear
structure is deleted, but the copy is unaffected.
If you use
to delete a structure that has multiple references, the function deletes the contents of the
StructClear
structure and all references point to the empty structure, as the following example shows:
<cfset myStruct.Key1="Adobe">
Structure before StructClear<br>
<cfdump var="#myStruct#">
<cfset myCopy=myStruct>
<cfset StructClear(myCopy)>
After Clear:<br>
myStruct: <cfdump var="#myStruct#"><br>
myCopy: <cfdump var="#myCopy#">
Looping through structures
You can loop through a structure to output its contents, as the following example shows:
StructDelete
function to delete all the data in a structure but keep the structure instance itself,
Last updated 8/5/2010
function, as follows:
function, the specified
StructCopy
101

Advertisement

Table of Contents
loading

Table of Contents