View comments | RSS feed

StructClear

Description

Removes all data from a structure.

Returns

True, on successful execution; False, otherwise.

Category

Structure functions

Function syntax

StructClear(structure)

See also

Structure functions; Modifying a ColdFusion XML object in Using XML and WDDX in ColdFusion MX Developer's Guide

History

ColdFusion MX: Changed behavior: this function can be used on XML objects.

Parameters

Parameter Description

structure

Structure to clear

Usage

Do not call this function on a session variable. For more information, see TechNote 14143, "ColdFusion 4.5 and the StructClear(Session) function," at www.coldfusion.com/Support/KnowledgeBase/SearchForm.cfm. (The article applies to ColdFusion 4.5, 5.x, and ColdFusion MX.)

Example

<!--- Shows StructClear function. Calls cf_addemployee custom tag which 
   uses the addemployee.cfm file. --->
<body>
<h1>Add New Employees</h1>
<!--- Establish params 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);
   StructInsert(employee, "lastname", Form.lastname);
   StructInsert(employee, "email", Form.email);
   StructInsert(employee, "phone", Form.phone);
   StructInsert(employee, "department", Form.department); 
  </cfscript> 
 </cfoutput>
<!--- Call the custom tag that adds employees --->
 <cf_addemployee empinfo = "#employee#">
 <cfscript>StructClear(employee);</cfscript> 
 </cfif>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


jrunrandy said on Jun 29, 2005 at 12:52 PM :
The TechNote listed in this discussion does not apply to ColdFusion MX 7. It should not have been included for this release.
DracTK said on Jun 5, 2007 at 4:31 PM :
When you call this function on client scope you will experience the "500 Null" error at the bottom of the page. The reason for this is Jrun bug - it needs client variable hitcount (when functionality is turned on). To work around this issue you need to have <cfset client.hitcount = 1 /> after the call to structClear(client). The error text will include "JRun Servlet Error".

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000634.htm