Name

StructGet — New as of ColdFusion 4.5.1 SP2

Synopsis

StructGet("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. 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. The StructGet( ) function can also be used to create nested one-dimensional arrays. The following example demonstrates the use of this function:

<!--- 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> <!--- create the Scores array ---> <CFSET test = StructGet("Scores[1].Mary")> <CFSET test.Test = 100> <CFOUTPUT> Is Temp1 a Struct? #IsStruct(Temp1)#<BR>Keys: #StructKeyList(Temp1)#<BR> Is Temp2 a Struct? #IsStruct(Temp2)#<BR>Keys: #StructKeyList(Temp2)#<BR> <HR NOSHADE> Is Grades a Structure: #IsStruct(Grades)#<BR>Keys: #StructKeyList(Grades)#<BR> Is Grades.Mary a Structure: #IsStruct(Grades.Mary)#<BR> Keys: #StructKeyList(Grades.Mary)#<BR> Is Grades.Tom a Structure: #IsStruct(Grades.Tom)#<BR> Keys: #StructKeyList(Grades.Tom)#<BR> ...

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.