View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > StructAppend PreviousNext

StructAppend

Appends one structure to another.

True, upon successful completion; False, otherwise.

Structure functions

StructAppend(struct1, struct2, overwriteFlag)

Structure functions

ColdFusion MX: Changed behavior: this function can be used on XML objects.

Parameter

Description

struct1

Structure to append.

struct2

Structure that contains the data to append to struct1

overwriteFlag

  • Yes: values in struct2 overwrite corresponding values in struct1. Default.
  • No

This function appends the fields and values of struct2 to struct1; struct2 is not modified. If struct1 already contains a field of struct2, overwriteFlag determines whether the value in struct2 overwrites it.

A structure's keys are unordered.

<html>
<body>
<!---- Create a Name structure --->
<cfset nameCLK=StructNew()>
<cfset nameCLK.first="Chris">
<cfset nameCLK.middle="Lloyd">
<cfset nameCLK.last="Gilson">
<!--- Create an address struct --->
<cfset addrCLK=StructNew()>
<cfset addrCLK.street="17 Gigantic Rd">
<cfset addrCLK.city="Watertown">
<cfset addrCLK.state="MA">
<cfset addrCLK.zip="02472">
<!---- Create a Person structure --->
<cfset personCLK=StructNew()>
<cfset personCLK.name=#nameCLK#>
<cfset personCLK.addr=#addrCLK#>
<!--- Display the contents of the person struct before the Append --->
<p>
The person struct <b>before</b> the Append call:<br>
<cfloop collection=#personCLK# item="myItem">
<cfoutput>
#myItem#<br>
</cfoutput>
</cfloop>
<!--- Merge the Name struct into the top-level person struct --->
<cfset bSuccess = StructAppend( personCLK, addrCLK )>

<!--- Display the contents of the person struct, after the Append --->
<p>
The person struct <b>after</b> the Append call:<br>
<cfloop collection=#personCLK# item="myItem">
   <cfoutput>
      #myItem#<br>
   </cfoutput>
</cfloop>

Contents > CFML Reference > ColdFusion Functions > StructAppend PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


Adam Cameron said on Mar 29, 2004 at 8:01 PM :
The description for the "struct1" parameter seems to be wrong. struct1 is the "struct to be appended TO", not the "struct to append".

"to append" means "to add to the end of [something]", not "to extend".

The difference might be subtle, but in the context, being as clear as possible might help.

Cheers.
extdw_doc said on Jul 15, 2004 at 1:59 PM :
values for overwrite flag should be True or False rather
than Yes or No
mrnate said on May 23, 2007 at 1:17 PM :
Values can be true or false, or "yes" or "no", the former are direct boolean values, the latter are strings, so they would need to be quoted. Also numeric values are automatically translated into booleans, as they are anywhere in CF, where 0 is false and any nonzero number is true.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functa89.htm