Solved

Copy value from struct to struct??

Posted on 2004-09-01
5
177 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
  • 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove Index.php in Codeigniter 12 67
URL redirect 4 67
Server specifications for web hosting 7 93
spamming  on Hosted svrs? 6 98
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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