> OK, to be complete: If you use StructCopy on a structure of
> structures, you
> won't get a copies of the sub-structures, but rather pointers to the sub-
> structures of the original structure.
In theory, I would agree with this statement, but I just ran some basic
tests to prove/disprove it, and the results were a little more than
confusing. Here's what I did...
First, I set the cfadmin (CF 4.5.1) to strictly enforce the use of CFLOCK
when the application scope is accessed. Then I wrote up some code (included
below), which would create an application variable which was a struct in a
struct in a struct (three structs inside each other). I then "copied" the
application struct out of the application scope into a temporary variable
using three different methods, including both StructCopy() and Duplicate().
I then attempted to access the information in the temporary "copied" structs
using CFOUTPUT. Because of the cfadmin configuration, my test code should
throw errors when I attempt to access any information which was not actually
copied, but instead resides in a pointer. To my surprise, the only error
was thrown for the simple copy. I was able to access all three levels of
struct data with StructCopy() without getting a pointer error.
Go ahead, try the code yourself.
I am not sure what to make of this. Either StructCopy() and Duplicate()
BOTH make a complete copy of all substruct info, or CF doesn't correctly
enforce strict usage of CFLOCK like is should be. Or maybe I'm
misinterpreting something....
Comments?
-Cameron
--------------------
Cameron Childress
ElliptIQ Inc.
p.770.460.7277.232
f.770.460.0963
-----
<CFLOCK TIMEOUT="#AppLockTimeout#" SCOPE="Application" TYPE="Exclusive">
<CFSCRIPT>
// root struct
Application.tmpStruct = StructNew();
Application.tmpStruct['one'] = 'one level deep';
// substruct
Application.tmpStruct['tmpSubStruct'] = StructNew();
Application.tmpStruct['tmpSubStruct']['two'] = 'two levels deep';
// sub-substruct
Application.tmpStruct['tmpSubStruct']['tmpSubSubStruct'] = StructNew();
Application.tmpStruct['tmpSubStruct']['tmpSubSubStruct']['three'] = 'three
levels deep';
// copy struct into tmp var three different ways
tmpPointer = Application.tmpStruct;
tmpStructCopy = StructCopy(Application.tmpStruct);
tmpDuplicate = Duplicate(Application.tmpStruct);
</CFSCRIPT>
</CFLOCK>
<CFTRY>
<CFOUTPUT>tmpPointer: #tmpPointer['one']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">tmpPointer is a pointer<BR></CFCATCH>
</CFTRY>
<HR>
<CFTRY>
<CFOUTPUT>tmpStructCopy: #tmpStructCopy['one']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">tmpStructCopy is a pointer<BR></CFCATCH>
</CFTRY>
<HR>
<CFTRY>
<CFOUTPUT>tmpStructCopy:
#tmpStructCopy['tmpSubStruct']['two']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">StructCopy creates pointers to
substructs<BR></CFCATCH>
</CFTRY>
<HR>
<CFTRY>
<CFOUTPUT>tmpStructCopy:
#tmpStructCopy['tmpSubStruct']['tmpSubSubStruct']['three']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">StructCopy creates pointers to
sub-substructs<BR></CFCATCH>
</CFTRY>
<HR>
<CFTRY>
<CFOUTPUT>tmpDuplicate: #tmpDuplicate['one']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">tmpDuplicate is a pointer<BR></CFCATCH>
</CFTRY>
<HR>
<CFTRY>
<CFOUTPUT>tmpDuplicate:
#tmpDuplicate['tmpSubStruct']['two']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">Duplicate creates pointers to
substructs<BR></CFCATCH>
</CFTRY>
<HR>
<CFTRY>
<CFOUTPUT>tmpDuplicate:
#tmpDuplicate['tmpSubStruct']['tmpSubSubStruct']['three']#<BR></CFOUTPUT>
<CFCATCH TYPE="Any">Duplicate creates pointers to
sub-substructs<BR></CFCATCH>
</CFTRY>
> -----Original Message-----
> From: Jeff Peters [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, November 05, 2000 12:43 PM
> To: Fusebox
> Subject: Re: OT but URGENT: duplicate function...
>
>
> OK, to be complete: If you use StructCopy on a structure of
> structures, you
> won't get a copies of the sub-structures, but rather pointers to the sub-
> structures of the original structure.
>
> Since the intent of StructCopy was to provide a separate,
> non-pointer copy of a
> structure (as opposed to the pointers created by <cfset newStruct
> = myStruct>),
> I maintain that StructCopy won't actually COPY a structure of
> structures.
> Duplicate, on the other hand, creates a separate, legit copy of
> the original
> structure, including substructures, sans pointers.
>
> What do you want folks to do, Fred, read the documentation> ;>
>
> - Jeff
>
> On 5 Nov 00, at 0:14, Fred T. Sanders wrote:
>
> > That's almost correct!
> >
> > ----- Original Message -----
> > From: "Jeff Peters" <[EMAIL PROTECTED]>
> > To: "Fusebox" <[EMAIL PROTECTED]>
> > Sent: Saturday, November 04, 2000 10:02 PM
> > Subject: RE: OT but URGENT: duplicate function...
> >
> >
> > > On 3 Nov 00, at 11:21, Jack Holt wrote:
> > >
> > > > Did I miss a message that generated this question? What duplicate
> > function?
> > >
> > > The new Duplicate() function is similar to the older StructCopy()
> > function,
> > > with one big difference: Where StructCopy() won't copy a structure of
> > > structures, Duplicate() will.
> > >
> > > - Jeff
> > >
> > > ==============================================================
> > > | Jeffrey S. Peters | "Specialization is for insects." |
> > > | [EMAIL PROTECTED] | - Lazarus Long |
> > > ==============================================================
> > >
> --------------------------------------------------------------------------
> > ----
> > > To Unsubscribe visit
> >
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
> send a message to [EMAIL PROTECTED] with 'unsubscribe' in
> the body.
> >
>
> --------------------------------------------------------------------------
----
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
send
a message to [EMAIL PROTECTED] with 'unsubscribe' in the
body.
==============================================================
| Jeffrey S. Peters | "Specialization is for insects." |
| [EMAIL PROTECTED] | - Lazarus Long |
==============================================================
----------------------------------------------------------------------------
--
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.