StructKeyExists

Description

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

Category

Structure functions

Syntax


StructKeyExists(structure, key) 

See also

StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear

Parameters

Parameter
Description
structure
Structure to test
key
Key to test

Usage

This function throws an exception if structure does not exist.

Example

<!--- This example illustrates usage of StructKeyExists. --->

<P>This file is similar to addemployee.cfm, which is called

by StructNew, StructClear, and StructDelete. To test this file,

copy the &LT;CFELSEif&GT; statement to the appropriate place

in addemployee.cfm. It is an example of a custom tag used 

to add employees. Employee information is passed through the 

employee structure (the EMPINFO attribute). In UNIX, you must 

also add the Emp_ID.



<cfswitch expression = "#ThisTag.ExecutionMode#">

  <cfcase value = "start">

   <cfif StructIsEmpty(attributes.EMPINFO)>

    <cfoutput>Error. No employee data was passed.</cfoutput>

     <cfexit method = "ExitTag">

   <cfelseIf NOT StructKeyExists(attributes.EMPINFO, "department")>

    <cfscript>StructUpdate(attributes.EMPINFO, "department",

      "Unassigned");

    </cfscript>

    <cfexit method = "ExitTag">

       <cfelse>

     ...





Banner.Novgorod.Ru