Well I had a problem, but as I was typing the below I figured it out.
Instead of deleting my email though, I thought I would send it anyway in
case this helps anyone else with nested structures...
I have a set of nested structures that I dynamically create from a query, so
I only know the top level structure name.
I need to know the values of the nasted structure keys are with out knowing
the structures name. I'll do a quick example.
<cfset parentStructure = StructNew()>
<cfloop...>
<cfset temp = StructNew()>
<cfset temp[keyval1] = 1>
<cfset temp[keyval2] = 2>
...and so on
<cfset parentStructure[keyval1] = temp>
</cfloop>
So I have nested the structures now and I can refer to the key values if I
know what the value of 'keyval1' is.
I can also get a list of all of the keys in 'parentStructure' with
StructKeyList().
My problem was that when I looped over the StructKeyList and then using that
value in my second loop over the collection, the variable was not evaluating
correctly.
<cfloop list="StructKeyList(parentStructure)" index="struct">
<cfloop collection="#parentStructure[struct]#" item="key">
This is where I had my problem. Dot Notation does not work in the second
collection loop, and looping over the StructKeyList was unnecessary.
Here is what works very well.
<cfloop collection="#parentStructure#" item="key">
<cfloop collection="#parentStructure[key]#" item="key2">
<cfoutput>#key2# #evaluate("parentStructure" & "." & "#key#" & "." &
"#key2#")#</cfoutput><br>
</cfloop>
</cfloop>
Anyway, my problem is solved. If anyone has a better way to do this, I'm all
ears
jon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists