| CFML Reference
|
|
ColdFusion Functions
|
StructDelete
Description
Removes an item from a structure.
Category
Structure functions
Syntax
StructDelete(structure, key [, indicatenotexisting ])
See also
StructClear, StructFind, StructInsert, StructIsEmpty, StructKeyArray, StructKeyExists, StructKeyList, StructCount, StructNew, StructUpdate, StructAppend, StructGet, StructSort, StructFindKey, StructClear
Parameters
| Parameter |
Description |
structure
|
Structure that contains the item to remove
|
key
|
Item to remove
|
indicatenotexisting
|
Indicates whether the function returns FALSE if key does not exist. The default is FALSE-the function returns Yes regardless of whether key exists. If you specify TRUE, the function returns Yes if key exists and No if it does not.
|
Example <!--- This example shows how to use the StructDelete function. --->
<html>
<head>
<title>StructDelete Function</title>
</head>
<basefont face = "Arial, Helvetica" size = 2>
<body bgcolor = "#FFFFD5">
<H3>StructDelete Function</H3>
<P>
This example uses the StructInsert and StructDelete functions.
<!--- Establish parms for first time through --->
<CFPARAM name = "firstname" DEFAULT = "Mary">
<CFPARAM name = "lastname" DEFAULT = "Torvath">
<CFPARAM name = "email" DEFAULT = "mtorvath@allaire.com">
<CFPARAM name = "phone" DEFAULT = "777-777-7777">
<CFPARAM name = "department" DEFAULT = "Documentation">
<cfif IsDefined("FORM.Delete")>
<cfoutput>
Field to be deleted: #form.field#
</cfoutput>
<P>
<CFScript>
employee = StructNew();
StructInsert(employee, "firstname", firstname);
StructInsert(employee, "lastname", lastname);
StructInsert(employee, "email", email);
StructInsert(employee, "phone", phone);
StructInsert(employee, "department", department);
</CFScript>
<cfoutput>
employee is a structure: #IsStruct(employee)#
</cfoutput>
<cfset rc = StructDelete(employee, "#form.field#", "True")>
<cfoutput>
<P>Did I delete the field "#form.field#"? The code indicates: #rc#
</P>
</cfoutput>
</cfif>
<cfif NOT IsDefined("FORM.Delete")>
<form action = "structdelete.cfm" method = "post">
<P>Select the field to be deleted:
<select name = "field">
<option value = "firstname">first name
<option value = "lastname">last name
<option value = "email">email
<option value = "phone">phone
<option value = "department">department
</select>
<input type = "submit" name = "Delete" value = "Delete">
</FORM>
</cfif>
</body>
</html>
|
Copyright © 2001, Macromedia Inc. All rights reserved. |
|
|