structIsEmpty

Description

Determines whether a structure contains data.

Categories

History

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

Syntax

StructIsEmpty(structure)

Attributes

AttributeDescriptionRequiredDefault
structureStructure to test

Returns

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

Example

<!--- This example illustrates use of StructIsEmpty. ---> 
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>