Returns the number of keys in the specified structure.
See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, and StructUpdate.
StructCount(structure)
Structure to be accessed.
This function throws an exception if structure does not exist.
<!--------------------------------------------------------------------- This example shows how to use the StructInsert, StructNew, and StructCount functions. ----------------------------------------------------------------------- > <html> <head> <title>StructCount Function</title> </head> <BASEFONT FACE="Arial, Helvetica" SIZE=2> <BODY bgcolor="#FFFFD5"> <h3>StructCount Example</h3> <h3>Add New Employees</h3> <P> <!---------------------------------------------------------------------- This example shows how to use the StructNew, StructInsert, and StructCount functions. -----------------------------------------------------------------------> <HTML> <HEAD> <title>Add New Employees</title> </HEAD> <BODY> <H3>Add New Employees</H3> <!--- Establish parms for first time through ---> <CFIF NOT IsDefined("FORM.firstname")> <CFSET FORM.firstname=""> </CFIF> <CFIF NOT IsDefined("FORM.lastname")> <CFSET FORM.lastname=""> </CFIF> <CFIF NOT IsDefined("FORM.email")> <CFSET FORM.email=""> </CFIF> <CFIF NOT IsDefined("FORM.phone")> <CFSET FORM.phone=""> </CFIF> <CFIF NOT IsDefined("FORM.department")> <CFSET FORM.department=""> </CFIF> <CFIF FORM.firstname EQ ""> <P>Please fill out the form. <CFELSE> <CFSET employee=StructNew()> <CFSET retCode=StructInsert(employee, "firstname", FORM.firstname)> <CFSET retCode=StructInsert(employee, "lastname", FORM.lastname)> <CFSET retCode=StructInsert(employee, "email", FORM.email)> <CFSET retCode=StructInsert(employee, "phone", FORM.phone)> <CFSET retCode=StructInsert(employee, "department", FORM.department)> <CFOUTPUT> <P>There are #StructCount(employee)# fields in the new structure.</P> <P>First name is #StructFind(employee, "firstname")#</P> <P>Last name is #StructFind(employee, "lastname")#</P> <P>EMail is #StructFind(employee, "email")#</P> <P>Phone is #StructFind(employee, "phone")#</P> <P>Department is #StructFind(employee, "department")#</P> </CFOUTPUT> <!---------------------------------------------------------------------- Write code to add the employee in the database. -----------------------------------------------------------------------> </CFIF> <Hr> <FORM action="structinsert.cfm" method="post"> <P>First Name: <INPUT name="firstname" type="text" hspace="30" maxlength="30"> <P>Last Name: <INPUT name="lastname" type="text" hspace="30" maxlength="30"> <P>EMail: <INPUT name="email" type="text" hspace="30" maxlength="30"> <P>Phone: <INPUT name="phone" type="text" hspace="20" maxlength="20"> <P>Department: <INPUT name="department" type="text" hspace="30" maxlength="30"> <P> <INPUT type="submit" value="OK"> </FORM> </BODY> </HTML>