Adobe ColdFusion 8

StructNew

Description

Creates a structure.

Returns

A structure.

Category

Structure functions

Function syntax

StructNew()

See also

Structure functions; "Structure functions" in the ColdFusion Developer's Guide

Parameters

None

Example

<!--- Shows StructNew. Calls CF_ADDEMPLOYEE, which uses the |
    addemployee.cfm file to add employee record to database. --->
<h1>Add New Employees</h1>
<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>