Solved

Copy value from struct to struct??

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now