Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

Name

StructGet

Synopsis

                  
                  
                  StructGet("path")

Returns a structure (flat or nested) from the specified path. Allows you to create nested structures without the need for multiple StructNew( ) calls. StructGet( ) takes a single argument, path, that specifies the path to the nested structure (including XML document objects) you want to return. StructGet( ) returns a pointer to the substructure specified as the last element in path. The StructGet( ) function automatically creates all the necessary structures and substructures specified in path if they do not exist. The StructGet( ) function can also be used to create nested one-dimensional arrays. The following example demonstrates the use of this function for creating a nested structure:

<!--- Create the Grades.Mary structure --->
<cfset temp1 = StructGet("Grades.Mary")>
<cfset temp1.Test1 = 98>                 
<cfset temp1.Test2 = 92>
<cfset temp1.Test3 = 100>
<cfset temp1.Test4 = 90>
   
<!--- Create the Grades.Tom structure --->
<cfset temp2 = StructGet("Grades.Tom")>
<cfset temp2.Test1 = 96>                 
<cfset temp2.Test2 = 88>
<cfset temp2.Test3 = 94>
<cfset temp2.Test4 = 90>
   
<cfdump var="#Grades#">

You can also use StructGet( ) to return the structures from an XML document object as this example demonstrates:

<cfset MyEmployees = QueryNew("Name,Title")> <cfset QueryAddRow(MyEmployees, 3)> <cfset QuerySetCell(MyEmployees, "Name", "Pere Money", 1)> <cfset QuerySetCell(MyEmployees, "Title", "President", 1)> <cfset QuerySetCell(MyEmployees, "Name", "Aaron Ridge", 2)> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page