StructFind

Returns the value associated with the specified key in the specified structure.

See also StructClear, StructDelete, StructInsert, StructIsEmpty, StructKeyArray, StructCount, StructKeyExists, and StructUpdate.

Syntax

StructFind(structure, key)
structure

Structure containing the value to be returned.

key

Key whose value is returned.

Usage

This function throws an exception if structure does not exist.

Example

<!---------------------------------------------------------------------- 
This example shows how to use the StructNew, StructInsert, and StructFind 
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>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:&nbsp;
<INPUT name="firstname" type="text" hspace="30" maxlength="30">
<P>Last Name:&nbsp;
<INPUT name="lastname" type="text" hspace="30" maxlength="30">
<P>EMail:&nbsp;
<INPUT name="email" type="text" hspace="30" maxlength="30">
<P>Phone:&nbsp;
<INPUT name="phone" type="text" hspace="20" maxlength="20">
<P>Department:&nbsp;
<INPUT name="department" type="text" hspace="30" maxlength="30">

<P>
<INPUT type="submit" value="OK">
</FORM>

</BODY>
</HTML>