Name

StructKeyExists

Synopsis

StructKeyExists(structure, key)

Checks for the existence of key in the specified structure. Returns True if the key exists or False if it doesn’t. The following example checks for the existence of different keys in a structure called Stock:

<CFSET Stock = StructNew(  )>
<CFSET Stock.Company = "Allaire">
<CFSET Stock.Ticker = "ALLR">
<CFSET Stock.Exchange = "NASDAQ">
<CFSET Stock.Price = "66.25">
<CFSET Stock.Change = "+0.375">
<CFSET Stock.LastTradeTime = "10:17AM">
<CFSET Stock.LastTradeDate = "05/17/1999">
<CFSET Stock.Volume = "8300">

<CFIF StructKeyExists(Stock, "company")>
  The key <B>company</b> exists in the structure called <B>Stock</B>.
<CFELSE>
  The key <B>company</b> doesn't exist in the structure called <B>Stock</B>.
</CFIF>
<P>
<CFIF StructKeyExists(Stock, "address")>
  The key <B>address</b> exists in the structure called <B>Stock</B>.
<CFELSE>
  The key <B>address</b> doesn't exist in the structure called <B>Stock</B>.
</CFIF>

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.