Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 101

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Code
<cfoutput>
Value of the first key<br>
#mystruct.key1#<br>
#mystruct["key1"]#<br>
#mystruct[key1Var]#<br>
<br>
<br>
Value of the second entry in the key2 array<br>
#myStruct.key2[2]#<br>
#myStruct["key2"][2]#<br>
#myStruct[key2Var][2]#<br>
#myStruct[key2Var][var2]#<br>
<br>
Value of the struct2key2 entry in the key3
structure<br>
#myStruct.key3.struct2key2#<br>
#myStruct["key3"]["struct2key2"]#<br>
#myStruct[key3Var]["struct2key2"]#<br>
#myStruct.key3["struct2key2"]#<br>
#myStruct["key3"].struct2key2#<br>
<br>
Creating and using structures
The sample code in the following discussions uses a structure called employee, which is used to add new employees to
a corporate information system.
Creating structures
In ColdFusion, you can create structures explicitly by using a function, and then populate the structure using
assignment statements or functions, or you can create the structure implicitly by using an assignment statement.
Creating structures using functions
You can create structures by assigning a variable name to the structure with the
<cfset structName = StructNew()>
For example, to create a structure named departments, use the following syntax:
<cfset departments = StructNew()>
This statement creates an empty structure to which you can add data.
Creating structures implicitly
You can create an empty structure implicitly, as in the following example:
<cfset myStruct = {}>
Description
Output the value of the key1 (string) entry using the following
notation:
object.property notation
associative array notation with a constant
associative array notation with a variable
Output the value of the second entry in the key2 array using the
following notation:
object.property notation
associative array notation with a constant
associative array notation with a variable
associative array notation with variables for both the array and the
array index
Output the value of second entry in the key3 embedded structure
using the following notation:
object.property notation
associative array notation with two constants
associative array notation with a variable and a constant
object.property notation followed by associative array notation
associative array notation followed by object.property notation
Last updated 1/20/2012
function as follows:
StructNew
96

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents