Getting Information About Structures - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

Creating and Using Structures

Getting information about structures

To find out if a given value represents a structure, use the
IsStruct(variable)
This function returns True if variable is a structure.
Structures are not indexed numerically, so to find out how many name-value pairs
exist in a structure, use the StructCount function, as in this example:
StructCount(employee)
To discover whether a specific Structure contains data, use the StructIsEmpty
function:
StructIsEmpty(structure_name)
This function returns True if the structure is empty and False if it contains data.
Finding a specific key and its value
To learn whether a specific key exists in a structure, use the StructKeyExists function:
StructKeyExists(structure_name, key)
If the name of the key is known in advance, you can use the ColdFusion function
IsDefined, as in this example:
<cfset temp=IsDefined("structure_name.key")>
But if the key is dynamic, or contains special characters, you must use the
StructKeyExists function:
<cfset temp=StructKeyExists(structure_name, key)>
You can also use the
example:
<cfset keyvalue=StructFind(structure_name, key)>
Getting a list of keys in a structure
To get a list of the keys in a CFML structure, you use the StructKeyList function:
<cfset temp=StructKeyList(structure_name, [delimiter] )>
The delimiter can be any delimiter, but the default is a comma ( , ).
The StructKeyArray function returns an array of keys in a structure:
<cfset temp=StructKeyArray(structure_name)>
Note
The
particular order. Use the
StructFind
and
StructKeyList
function to find a key and return its value, as in this
functions do not return keys in any
StructKeyArray
or
ListSort
ArraySort
function:
IsStruct
function to sort the results.
129

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents