StructUpdate

Description

Updates a key with a value.

Return value

True, on successful execution; if the structure does not exist, ColdFusion throws an error.

Category

Structure functions

Syntax

StructUpdate(structure, key, value)

See also

Structure functions

History

New in ColdFusion MX: this function can be used on XML objects.

Parameters

Parameter Description
structure
Structure to update
key
Key, the value of which to update
value
New value

Example

<!--- This example shows the use of StructUpdate. --->
<p>This file is similar to addemployee.cfm, which is called by StructNew,
StructClear, and StructDelete. To test this file, copy the
&LT;CFELSEIF&GT; statement to the appropriate place in 
addemployee.cfm. It is an example of a custom tag used to add 
employees. Employee information is passed through the employee 
structure (the EMPINFO attribute). In UNIX, you must also add the Emp_ID.

<cfswitch expression = "#ThisTag.ExecutionMode#">
  <cfcase value = "start">
   <cfif StructIsEmpty(attributes.EMPINFO)>
    <cfoutput>Error. No employee data was passed.</cfoutput>
    <cfexit method = "ExitTag">
   <cfelseIf StructFind(attributes.EMPINFO, "department") EQ "">
    <cfscript>
     StructUpdate(attributes.EMPINFO, "department", "Unassigned");
    </cfscript>
    <cfexit method = "ExitTag">
      <cfelse> 

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

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

 

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

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt2103.htm