User Guide

538 CFML Language Reference
StructNew
Returns a new structure.
See also StructClear, StructDelete, StructFind, StructInsert, StructIsEmpty,
StructKeyArray, StructCount, and StructUpdate.
Syntax StructNew()
Example <!----------------------------------------------------------------------
This example shows how to use the StructNew function. It calls
the CF_ADDEMPLOYEE custom tag, which uses the addemployee.cfm file
to add the employee record to a database.
----------------------------------------------------------------------->
<HTML>
<HEAD>
<TITLE>Add New Employees</TITLE>
</HEAD>
<BODY>
<H1>Add New Employees</H1>
<!--- Establish parameters for first time through --->
<CFPARAM NAME="FORM.firstname" DEFAULT="">
<CFPARAM NAME="FORM.lastname" DEFAULT="">
<CFPARAM NAME="FORM.email" DEFAULT="">
<CFPARAM NAME="FORM.phone" DEFAULT="">
<CFPARAM NAME="FORM.department" DEFAULT="">
<CFIF FORM.firstname EQ "">
<P>Please fill out the form.
<CFELSE>
<CFOUTPUT>
<CFSCRIPT>
employee=StructNew();
StructInsert(employee, "firstname", FORM.firstname);
StructInsert(employee, "lastname", FORM.lastname);
StructInsert(employee, "email", FORM.email);
StructInsert(employee, "phone", FORM.phone);
StructInsert(employee, "department", FORM.department);
</CFSCRIPT>
<P>First name is #StructFind(employee, "firstname")#
<P>Last name is #StructFind(employee, "lastname")#
<P>EMail is #StructFind(employee, "email")#
<P>Phone is #StructFind(employee, "phone")#
<P>Department is #StructFind(employee, "department")#
</CFOUTPUT>
<!--- Call the custom tag that adds employees --->
<CF_ADDEMPLOYEE EMPINFO="#employee#">
</CFIF>
...