StructUpdate(structure, key, value)
Updates a key with a value. Returns Yes if the function is successful and throws an exception if an error occurs.
StructClear,
StructDelete,
StructFind,
StructInsert,
StructIsEmpty,
StructKeyArray,
StructCount,
StructNew,
StructAppend,
StructGet,
StructSort,
StructFindKey,
StructClear
Parameter |
Description |
---|---|
structure |
Structure to update |
key |
Key whose value is updated |
value |
New value |
This function throws an exception if structure does not exist.
<!--- This example illustrates usage of StructUpdate. ---> <P>This file is similar to addemployee.cfm, which is called by StructNew, StructClear, and StructDelete. To test this file, copy the <CFELSEIF> 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> ...