User Guide Cancel

StructAppend

 

Description

Appends one structure to another.

Returns

True, upon successful completion; False, otherwise.

Category

Syntax

StructAppend(struct1, struct2, overwriteFlag)
StructAppend(struct1, struct2, overwriteFlag)
StructAppend(struct1, struct2, overwriteFlag)

See also

Structure functionsModifying a ColdFusion XML object in the Developing ColdFusion Applications guide.

History

ColdFusion (2018 release): Introduced named parameters.

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

Parameters

Parameter

Description

struct1

Structure to which struct2 is appended.

struct2

Structure that contains the data to append to struct1

overwriteFlag

  • True or Yes: values in struct2 overwrite corresponding values in struct1. Default.
  • False or No: values in struct2 do not overwrite corresponding values in struct1.

Example

<cfscript>
myS1={Name:"John",Age:30,Dept:"Marketing"};
myS2={Street:"My Street",Avenue:"My Avenue",Building:50,zip:10101};
WriteOutput("Appended Structs:");
StructAppend(myS1,myS2,true);// Returns true
// Displays appended structs
WriteDump(myS1);
</cfscript>
<cfscript> myS1={Name:"John",Age:30,Dept:"Marketing"}; myS2={Street:"My Street",Avenue:"My Avenue",Building:50,zip:10101}; WriteOutput("Appended Structs:"); StructAppend(myS1,myS2,true);// Returns true // Displays appended structs WriteDump(myS1); </cfscript>
<cfscript>
       myS1={Name:"John",Age:30,Dept:"Marketing"};
       myS2={Street:"My Street",Avenue:"My Avenue",Building:50,zip:10101};
       WriteOutput("Appended Structs:");
       StructAppend(myS1,myS2,true);// Returns true
       // Displays appended structs
       WriteDump(myS1);
</cfscript>

Output

structappend output
structappend output

Using member function

<cfscript>
myS1={Name:"John",Age:30,Dept:"Marketing"};
myS2={Street:"My Street",Avenue:"My Avenue",Building:50,zip:10101};
WriteOutput("Using member function:");
WriteDump(myS1.append(myS2));
</cfscript>
<cfscript> myS1={Name:"John",Age:30,Dept:"Marketing"}; myS2={Street:"My Street",Avenue:"My Avenue",Building:50,zip:10101}; WriteOutput("Using member function:"); WriteDump(myS1.append(myS2)); </cfscript>
<cfscript>
       myS1={Name:"John",Age:30,Dept:"Marketing"};
       myS2={Street:"My Street",Avenue:"My Avenue",Building:50,zip:10101};
       WriteOutput("Using member function:");
       WriteDump(myS1.append(myS2));
</cfscript>

Get help faster and easier

New user?