I am not clear exactly what you mean and I have never used StructFind(), but
this might be a good case???

.......................
Ben Nadel 
Web Developer
Nylon Technology
350 7th Avenue
Floor 10
New York, NY 10001
212.691.1134 x 14
212.691.3477 fax
www.nylontechnology.com
 
"Some people call me the space cowboy. Some people call me the gangster of
love."

-----Original Message-----
From: Tom McNeer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 27, 2006 5:50 PM
To: CF-Talk
Subject: Accessing structure dynamically

Hi,

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"?

Any help is greatly appreciated.

--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
530 Means St NW, Suite 110
Atlanta, GA 30318
404.589.0560




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244930
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to