Name

StructIsEmpty

Synopsis

                  
                  StructIsEmpty(structure)

Returns true if the specified structure contains no data or false if it contains data. StructIsEmpty( ) throws an error if the specified structure does not exist, so it’s generally a good idea to test for the existence of the structure first using IsDefined( ), before checking whether it is empty. The following example checks to see if the structure Employee is empty:

<cfset Employee=StructNew( )>
<cfset Employee.Name="Pere Money">
<cfset Employee.Title="President">
<cfset Employee.Department="Executive Management">
<cfset Employee.Email="pmoney@example.com">
<cfset Employee.PhoneExt="1234">
   
<cfif IsDefined('Employee')>
  <cfif StructIsEmpty(Employee)>
    The structure <b>Employee</b> is empty!
  <cfelse>
    The structure <b>Employee</b> is not empty.
  </cfif>
</cfif>

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.