Name

StructInsert

Synopsis

StructInsert(structure, key, value [, allowoverwrite])

Inserts key and value into structure. Returns Yes if the operation is successful and No if it isn’t. Setting the optional allowoverwrite parameter to True allows overwriting of existing keys. The default is False. Here’s an example that inserts key/value pairs into a structure called Stock:

<CFSET Stock = StructNew(  )>

<CFSET StructInsert(Stock, "company", "Allaire")>
<CFSET StructInsert(Stock, "ticker", "ALLR")>
<CFSET StructInsert(Stock, "exchange", "NASDAQ")>
<CFSET StructInsert(Stock, "price", "66.25")>
<CFSET StructInsert(Stock, "change", "+0.375")>
<CFSET StructInsert(Stock, "lasttradetime", "10:17AM")>
<CFSET StructInsert(Stock, "lasttradedate", "05/17/1999")>
<CFSET StructInsert(Stock, "volume", "8300")>

<CFOUTPUT>
<B>Company:</B> #Stock.company#<BR>
<B>Ticker:</B> #Stock.ticker#<BR>
<B>Exchange:</B> #Stock.exchange#<BR>
<B>Price:</B> #Stock.price#<BR>
<B>Change:</B> #Stock.change#<BR>
<B>Last Trade Time:</B> #Stock.lasttradetime#<BR>
<B>Last Trade Date:</B> #Stock.lasttradedate#<BR>
<B>Volume:</B> #Stock.volume#
</CFOUTPUT>

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.