528
StructInsert
Inserts the specified key-value pair into the specified structure. Returns Yes if the insert
was successful and No if an error occurs.
See also StructClear, StructDelete, StructFind, StructIsEmpty, StructKeyArray,
StructCount, StructKeyArray, and StructUpdate.
Syntax
StructInsert( structure , key , value [, allowoverwrite ] )
structure
Structure to contain the new key-value pair.
key
Key that contains the inserted value.
value
Value to be added.
allowoverwrite
Optionally indicates whether to allow overwriting an existing key. The default is
FALSE.
Usage
This function throws an exception if structure does not exist or if key exists and
allowoverwrite is set to FALSE.
Example
<!--- This example shows how to use the StructInsert
function. It calls the CF_ADDEMPLOYEE custom tag,
which uses the addemployee.cfm file. --->
<HTML>
<HEAD>
<TITLE>Add New Employees</TITLE>
</HEAD>
<BODY>
<H1>Add New Employees</H1>
<!--- Establish parms 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);
CFML Language Reference
--->
Need help?
Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?
Questions and answers