<cfset myArrayOfStructs = ArrayNew(1)>

<cfset myArrayOfStructs[1] = StructNew()>
<cfset myArrayOfStructs[1].FName = "Adrian">
<cfset myArrayOfStructs[1].LName = "Lynch">
<cfset myArrayOfStructs[1].EMail = "[EMAIL PROTECTED]">

<cfset myArrayOfStructs[2] = StructNew()>
<cfset myArrayOfStructs[2].FName = "Thane">
<cfset myArrayOfStructs[2].LName = "Sherrington">
<cfset myArrayOfStructs[2].EMail = "[EMAIL PROTECTED]">

<cfdump var="#myArrayOfStructs#">

That'll get you an array of structures. One thing to note, unlike this...

        myStruct.myKey = "somevalue"

.... which works in creating a struct, key and value...

        myArrayOfStructs[1].myKey = "somevalue"

.... will fail with an error. Hence the need for...

        myArrayOfStructs[1] = StructNew()

.... before using that index as a structure.

Ade


-----Original Message-----
From: Thane Sherrington [mailto:[EMAIL PROTECTED]
Sent: 24 April 2005 16:21
To: CF-Talk
Subject: Structures (probably a stupid question)


I'm trying to understand structures - I understand that they are like the
form scope in that I can access them as myStruct.myVar, but is there a way
to create an array of structures?  I'm thinking it would be nice to create
a structure like:

myStruct.FName
myStruct.LName
myStruct.EMail

And then add people to that sort of like a virtual table that I could later
loop through and add to a real table.

It appears from the reading I've done that one can, but I can't find a
clear example of it.  I'm looking for something will work in CF5 and up.

Thanks,

T
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.10.2 - Release Date: 21/04/2005


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204165
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