View comments | RSS feed

StructIsEmpty

Description

Determines whether a structure contains data.

Returns

True, if structure is empty; if structure does not exist, ColdFusion throws an exception.

Category

Decision functions, Structure functions

Function syntax

StructIsEmpty(structure)

See also

Structure functions; Modifying a ColdFusion XML object in Using XML and WDDX in ColdFusion MX Developer's Guide

History

ColdFusion MX: Changed behavior: this function can be used on XML objects.

Parameters

Parameter Description

structure

Structure to test

Example

<!--- This example illustrates use of StructIsEmpty. --->
<p>This file is identical to addemployee.cfm, which is called by StructNew,
StructClear, and StructDelete. It adds employees. Employee information
is passed through employee structure (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"> <cfelse> <!--- Add the employee; In UNIX, you must also add the Emp_ID ---> <cfquery name = "AddEmployee" datasource = "cfdocexamples"> INSERT INTO Employees (FirstName, LastName, Email, Phone, Department) VALUES <cfoutput> ( '#StructFind(attributes.EMPINFO, "firstname")#' , '#StructFind(attributes.EMPINFO, "lastname")#' , '#StructFind(attributes.EMPINFO, "email")#' , '#StructFind(attributes.EMPINFO, "phone")#' , '#StructFind(attributes.EMPINFO, "department")#' ) </cfoutput> </cfquery> </cfif> <cfoutput><hr>Employee Add Complete</cfoutput> </cfcase> </cfswitch>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


No screen name said on Jun 19, 2006 at 10:42 AM :
When you pass the Arguments struct to this function in a <cffunction/> block whose arguments are not required and no arguments are passed in, StructIsEmpty returns false, even though each member of Arguments is undefined. Is StructIsEmpty something more like "HasNoMembers"?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000643.htm