I'm jumping in late on this one, but I wanted to throw in my two cents.
Structures (and arrays) are *so* much easier in <cfscript>, it's not even funny.
<cfset payment = structNew()>
<cfloop query="queryName">
<cfscript>
if (NOT structKeyExists(payment, "pkWebUser") {
payment[pkWebUser] = structNew();
}
</cfscript>
</cfloop>
Throwing in the if statement prevents the structure from being overwritten if there
are duplicate records in the query. This way you can make nested structures much
easier.
(In case nobody else pointed it out, you don't need the dot when using the array
notation.)
Sharon
----- Original Message -----
From: "Kay Smoljak" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, April 11, 2002 5:11 AM
Subject: Dynamic structure key names
> Hi all,
>
> I'm stuck on the syntax for this. I have a structure. What I'm trying to
> do is loop over a query, and create a new structure (dynamically named
> with the primary key of the record as a structure key) with three values
> from that record. I think I must be doing something wrong syntax-wise,
> and I can't find any examples in the docs or the archives.
>
> I have tried these (within a query loop):
> <cfset payment.[due.pkWebUser] = StructNew()>
> <cfset payment.evaluate(due.pkWebUser) = StructNew()>
> <cfset payment.#due.pkWebUser# = StructNew()>
>
> But nothing is working so far. Any ideas on how to do this or how it can
> be done easier?
>
> Kay.
>
> ______________________________________________________
> Kay Smoljak - ColdFusion Developer - PerthWeb Pty Ltd
>
> Level 9/105 St George's Terrace - Perth - Western Australia
> Ph: (08) 9226 1366 Fax: (08) 9226 1375 www.perthweb.com.au
>
> http://developer.perthweb.com.au - Tools for Developers
> cfx_pwcamtech | cfx_pwimageproc | cfx_pwcardcyrpt
>
>
>
>
>
>
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists