User Guide Cancel

StructCount

 

Description

Counts the keys in a structure.

Returns

A number; if structure does not exist, throws an exception.

Category

Syntax

StructCount(structure)
StructCount(structure)
StructCount(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 access.

Example

<cfscript>
myStruct={a:1,b:2,c:3,d:4,e:5}; //Define the structure keys
myCount=StructCount(myStruct); //Count the number of keys in myStruct
WriteOutput(#myCount#); //Display value of myCount
</cfscript>
<cfscript> myStruct={a:1,b:2,c:3,d:4,e:5}; //Define the structure keys myCount=StructCount(myStruct); //Count the number of keys in myStruct WriteOutput(#myCount#); //Display value of myCount </cfscript>
<cfscript>
       myStruct={a:1,b:2,c:3,d:4,e:5}; //Define the structure keys
       myCount=StructCount(myStruct); //Count the number of keys in myStruct
       WriteOutput(#myCount#); //Display value of myCount
</cfscript>

Output

5

Using member function

<cfscript>
myStruct={a:1,b:2,c:3,d:4,e:5}; //Define the structure keys
WriteOutput(myStruct.count()); // Count the number of keys in input struct
</cfscript>
<cfscript> myStruct={a:1,b:2,c:3,d:4,e:5}; //Define the structure keys WriteOutput(myStruct.count()); // Count the number of keys in input struct </cfscript>
<cfscript>
       myStruct={a:1,b:2,c:3,d:4,e:5}; //Define the structure keys
       WriteOutput(myStruct.count()); // Count the number of keys in input struct
</cfscript>

Get help faster and easier

New user?