Name
StructAppend — New as of ColdFusion 4.5.1 SP2
Synopsis
StructAppend(structure1, structure2,
[,overwrite
])
Appends the contents of structure2
to
structure1
. After completion,
structure1
contains the newly appended
structure while structure2
remains
unchanged. Setting the optional overwrite
parameter to Yes
allows overwriting of existing
keys/values within the appended structure. The default value for
overwrite
is Yes
. The
following example demonstrates the StructAppend( )
function:
<!--- create the Stock structure ---> <CFSET Stock = StructNew( )> <CFSET Stock.Company = "Allaire"> <CFSET Stock.Ticker = "ALLR"> <CFSET Stock.Exchange = "NASDAQ"> <!--- create the TradeInfo structure ---> <CFSET TradeInfo = StructNew( )> <CFSET TradeInfo.Price = "66.25"> <CFSET TradeInfo.Change = "+0.375"> <CFSET TradeInfo.LastTradeTime = "10:17AM"> <CFSET TradeInfo.LastTradeDate = "05/17/1999"> <CFSET TradeInfo.Volume = "8300"> <!--- output the contents of the Stock structure ---> <CFSET MyKeyArray = StructKeyArray(Stock)> <H2>Stock Structure</H2> <TABLE> <TR><TH>Key</TH><TH>Value</TH></TR> <CFLOOP index="position" from="1" to="#ArrayLen(MyKeyArray)#"> <CFOUTPUT> <TR><TD>#MyKeyArray[position]#</TD><TD>#Stock[MyKeyArray[position]]#</TD></TR> </CFOUTPUT> </CFLOOP> </TABLE> <!--- output the contents of the TradeInfo structure ---> <CFSET MyKeyArray = StructKeyArray(TradeInfo)> <H2>TradeInfo Structure</H2> <TABLE> <TR><TH>Key</TH><TH>Value</TH></TR> <CFLOOP index="position" from="1" to="#ArrayLen(MyKeyArray)#"> ...
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.