StructKeyExists

Returns TRUE if the specified key is in the specified structure and FALSE if it is not.

See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructCount, StructKeyArray, and StructUpdate.

Syntax

StructKeyExists(structure, key)
structure

Structure to be tested.

key

Key to be tested.

Usage

This function throws an exception if structure does not exist.

Example

<!---------------------------------------------------------------
This example illustrates the use of IsStruct and StructIsEmpty. 
It assumes that you have created and assigned values to the fields of a 
structure named EMPINFO within an include file. Sometimes when
you have included a file that contains variable declarations, you
may not know if a variable is a structure or a scalar value.
This code not only checks to see if EMPINFO is a structure, it
also checks to see if its fields have been assigned values, and
checks for the existence of a particular field. 
----------------------------------------------------------------->
<CFIF IsStruct(EMPINFO)>
    <CFIF StructIsEmpty(EMPINFO)>
        <P>Error. EMPINFO is empty.</P>
    <CFELSE>
        <CFOUTPUT>
         <P>EMPINFO contains #StructCount(EMPINFO)# fields.
        </CFOUTPUT>
        <CFIF StructKeyExists(EMPINFO, phone)>
        <!--------------------------------------------------------
        Use CFQUERY to find out if this is a new number.
        ---------------------------------------------------------->
        </CFIF>
    </CFIF>
<CFELSE>
    <P>Error. EMPINFO is not a structure.</P>
</CFIF>
...