User Guide Cancel

StructIsEmpty

 

Description

Determines whether a structure contains data.

Returns

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

Category

Syntax

StructIsEmpty(structure)
StructIsEmpty(structure)
StructIsEmpty(structure)

See also

Structure functionsModifying a ColdFusion XML object in the Developing ColdFusion Applications

History

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

Parameters

Parameter

Description

structure

Structure to test.

Example

<cfscript>
myStruct = {a:1,b=2,c=3,d=4,e=5};
isEmpty=StructIsEmpty(myStruct); //Returns false since myStruct is not empty
WriteOutput(isEmpty & " | ");
// Try to find if struct is empty in a struct that does not exist
try{
StructIsEmpty(myAnotherStruct);
}
catch(any s){
WriteOutput(s.message); //Display required message
}
</cfscript>
<cfscript> myStruct = {a:1,b=2,c=3,d=4,e=5}; isEmpty=StructIsEmpty(myStruct); //Returns false since myStruct is not empty WriteOutput(isEmpty & " | "); // Try to find if struct is empty in a struct that does not exist try{ StructIsEmpty(myAnotherStruct); } catch(any s){ WriteOutput(s.message); //Display required message } </cfscript>
<cfscript>
       myStruct = {a:1,b=2,c=3,d=4,e=5};
       isEmpty=StructIsEmpty(myStruct); //Returns false since myStruct is not empty
       WriteOutput(isEmpty & " | ");
       // Try to find if struct is empty in a struct that does not exist
       try{
             StructIsEmpty(myAnotherStruct);
       }
       catch(any s){
             WriteOutput(s.message); //Display required message
       }
</cfscript>

Output

NO | Variable MYANOTHERSTRUCT is undefined.

Using member function

<cfscript>
myStruct = {a:1,b=2,c=3,d=4,e=5};
myEmpty=myStruct.isEmpty();
WriteOutput(myEmpty);
</cfscript>
<cfscript> myStruct = {a:1,b=2,c=3,d=4,e=5}; myEmpty=myStruct.isEmpty(); WriteOutput(myEmpty); </cfscript>
<cfscript>
       myStruct = {a:1,b=2,c=3,d=4,e=5};
       myEmpty=myStruct.isEmpty();
       WriteOutput(myEmpty);
</cfscript>

Output

Is struct myEmpty empty? : NO

Get help faster and easier

New user?