User Guide

130 Chapter 8 Handling Complex Data with Structures
Copying structures
To copy a structure, use the StructCopy function. This function takes the name of
the structure that you want to copy and returns a new structure with all the keys and
values of the named structure.
StructCopy(structure)
This function throws an exception if structure does not exist.
Use the StructCopy function when you want to create a physical copy of a structure.
You can also use assignment to create a copy by reference.
Deleting structures
To delete an individual name-value pair in a structure, use the StructDelete
function:
StructDelete(structure_name, key [, indicatenotexisting ])
This deletes the named key and its associated value. Note that the
indicatenotexisting parameter indicates whether the function returns False if the
named key does not exist. The default is False, which means that the function returns
Yes regardless of whether key exists. If you specify True for this parameter, the
function returns Yes if key exists and No if it does not.
You can also use the
StructClear function to delete all the data in a structure but
keep the structure instance itself:
StructClear(structure_name)
Structure example
Structures are particularly useful for grouping together a set of variables under a
single name. In the following example, structures are used to collect information
from a form, structinsert.cfm, and to submit that information to a custom tag at
addemployee.cfm.
This examples show how you can use a structure to pass information to a custom tag,
named
cf_addemployee. For information on creating and using custom tags, see
Reusing Code on page 171.
Example file structinsert.cfm
<!--- 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>