Copying Structures; Deleting Structures; Structure Example - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

130

Copying structures

To copy a structure, use the
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
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
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
"Reusing Code" on page 171.
Example file structinsert.cfm
<!--- This example shows how to use the StructInsert
<html>
<head>
<title>Add New Employees</title>
</head>
StructClear
. For information on creating and using custom tags, see
cf_addemployee
function. It calls the cf_addemployee custom tag,
which uses the addemployee.cfm file. --->
Chapter 8 Handling Complex Data with Structures
function. This function takes the name of
StructCopy
function to delete all the data in a structure but
StructDelete

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents