> I know that you can access a key in a CF structure dynamically, using > bracket notation, as in: > > <cfset structName[keyname] = 0 /> > > .... so that the "keyname" could be a variable, allowing you to access > the value with the keyname stored in the variable. > > But I need to go one level deeper. > > I have a struct of structs, where I need to access a key in the > second-level struct dynamically. > > Let's say I have: > > myStruct = structNew() > myStruct.subStruct1 = structNew() > myStruct.subStruct1.key1 = foo > myStruct.subStruct1.key2 = bar > myStruct.subStruct2.key1 = something > myStruct.subStruct2.key2 = nothing > > I know that I can do: > > myVariable = "subStruct1" > > and then reference: > > myStruct[myVariable].key1 > > .... and get the value "foo" > > But what if the keyname in the lower struct needs to be determined > dynamically? That is, what if I don't know that I want "key1," but > rather a key referenced by a variable. > > Out of curiosity, I tried nesting the brackets, to see if you could > access the inner struct that way: > > myStruct[myVariable[myVariable]] > > .... but that just caused the familiar "dereferencing a scalar" message. > > Does anyone know how to do this? Do I have to fall back on "Evaluate"?
myStruct[someKeyToMyStruct][someKeyToTheStructWithinSomeKeyToMyStruct] Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244931 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54