Copy value from struct to struct??

Posted on 2004-09-01
Medium Priority
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.


Question by:Westside2004
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
LVL 21

Expert Comment

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:

   <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]#>

The following code shows how StructCopy copies a nested structure:

  <cfset assignedCopy.nestedStruct = struct.nestedStruct>

To copy a structure entirely by value, use Duplicate.


Author Comment

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?


LVL 14

Expert Comment

by:Renante Entera
ID: 11959915
Hello Westside2004!

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


eNTRANCE2002 :-)
LVL 21

Accepted Solution

pinaldave earned 500 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.

LVL 21

Expert Comment

ID: 11960327
Smiles and good day,

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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