Solved

Copy value from struct to struct??

Posted on 2004-09-01
5
179 Views
Last Modified: 2013-12-24
How do you copy one of the values in a structure to another structure..

I know about duplicate(), but wanted to ask if there is a way to just copy 1 value from the structure...

My first thought woudl be to copy it to local variable scope, and the move it into structure I want???

Please let me know if possible.

Thanks

WS
0
Comment
Question by:Westside2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11959780
Hi Westside2004,

The following code shows how this function copies a structure that contains a string field, a number field, and a two-dimensional array at the top level:

<cfoutput>
   <cfset assignedCopy = StructNew()>
  <cfset assignedCopy.string = #struct.string#>
   <cfset assignedCopy.number = #struct.number#>
   <cfset assignedCopy.array = ArrayNew(2)>
   <cfset assignedCopy.array[1][1] = #struct.array[1][1]#>
   <cfset assignedCopy.array[1][2] = #sruct.array[1][2]#>
</cfoutput>

The following code shows how StructCopy copies a nested structure:

<cfoutput>
  <cfset assignedCopy.nestedStruct = struct.nestedStruct>
</cfoutput>

To copy a structure entirely by value, use Duplicate.

Regards,
---Pinal
0
 
LVL 1

Author Comment

by:Westside2004
ID: 11959897
I just need to copy one value from within the structure ideally..

The structure holds a bunch of other info, but I just want one specific key/value pair...

Can that be done?

Thanks

WS
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 11959915
Hello Westside2004!

You may browse this site for you reference on using arrays and structures :

http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/arrayStruct7.htm


Regards!
eNTRANCE2002 :-)
0
 
LVL 21

Accepted Solution

by:
pinaldave earned 125 total points
ID: 11960112
Hi Westside2004,

i think so we can do it.
<CFSET structone.var = structtwo.var2>
I do not see any problem with that.

Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11960327
Smiles and good day,
---Pinal
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question