Structs are like Pointers/Linked-Lists and "reference-based" 
data-structures
in other programming languages.  If you don't know what I'm talking 
abooot,
thats okay.  Just remember this simple example:

<cfset x=StructNew()>
<cfset y=x>

y is now x and x is now y for all intents and purposes.  any 
modifications
to y are made to x and visa versa.  you have 2 options.

option #1: Use StructCopy to copy "Item" to that array element
option #2: Set Item=StructNew after assigning the value.  Example:

// department mail addresses
// e-mail addresses and contact information dropped into an array of 
structs
to facilitate retrieval and updating

request.contact = arrayNew(1);

// DEPARTMENT 1
item = structNew();
item.department = 'Department 1;
item.name = 'Bill Jones;
item.email = '[EMAIL PROTECTED];

additem = arrayAppend(request.contact, item);

// DEPARTMENT 2
item=StructNew();
item.department = 'Department 2;
item.name = 'Joe Jones;
item.email = '[EMAIL PROTECTED];

additem = arrayAppend(request.contact, item);


::brendan avery 2.0
::310.779.2211
::[EMAIL PROTECTED]
::santa monica, california



-----Original Message-----
From: Owens, Howard [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 16:41
To: CF-Talk
Subject: array - structure question


On my Application.cfm page, I want to use an array to populate a 
feedback
form with contacts, and the response page with the corresponding e-mail
addresses in the "to" attribute.

This seemed more practical than storing the info in a database, for an
amount of data this limited, but still give some flexibility for making
changes down the road.

So here's a snip from within my CFScript:


// department mail addresses
// e-mail addresses and contact information dropped into an array of 
structs
to facilitate retrieval and updating

request.contact = arrayNew(1);
item = structNew();


// DEPARTMENT 1
item.department = 'Department 1;
item.name = 'Bill Jones;
item.email = '[EMAIL PROTECTED];

additem = arrayAppend(request.contact, item);

// DEPARTMENT 2
item.department = 'Department 2;
item.name = 'Joe Jones;
item.email = '[EMAIL PROTECTED];

additem = arrayAppend(request.contact, item);

 .... and so on.

The problem is, the last entry keeps overwriting the structures at each
array position.  In other words, request.contact[1] contains the data 
for
array position 10, and position 2 contains the data for 10 ... and so 
on.

Should position 1 of the array remember what it had initially and not 
get
over written by the time the 2 position is created, and so on?

How can I get each position in the array to have structures with 
discrete
and unique information?

H.


Howard Owens
Internet Operations Coordinator
www.insidevc.com
[EMAIL PROTECTED]
AIM: GoCatGo1956


______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
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

Reply via email to