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, StructInsert, and StructFind 
functions. 
----------------------------------------------------------------------->
<HTML>
<HEAD>
<title>Add New Employees</title>
</HEAD>

<BODY>
<H1>Add New Employees</H1>
    <CFSET employee= StructNew()>

<!--- Establish parameters 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 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>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>

</CFIF>
...