Structkeyexists - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

StructKeyExists

Description
Determines whether a specific key is present in a structure.
Returns
True, if key is in structure; if structure does not exist, ColdFusion throws an exception.
Category
Decision
functions,
Function syntax
StructKeyExists(structure, "key")
See also
Structure functions
Parameters
Parameter
structure
key
Usage
This function can sometimes be used in place of the
the URL and Form scopes, which are structures. The following pieces of code are equivalent:
cfif IsDefined("Form.JediMaster")>
<cfif StructKeyExists(Form,"JediMaster")>
A structure's keys are unordered.
Example
<!--- This example shows the use of StructKeyExists. --->
<p>This file is similar to addemployee.cfm, which is called by StructNew,
StructClear, and StructDelete. To test, copy the &LT;CFELSEif&GT;
statement to the appropriate place in addemployee.cfm. It is a custom tag
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>
710
Chapter 3: ColdFusion Functions
Structure functions
Description
Name of structure to test
Key to test
function, when working with
IsDefined

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents