Skip to Content
Programming ColdFusion
book

Programming ColdFusion

by Rob Brooks-Bilson
August 2001
Intermediate to advanced
976 pages
38h 8m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion

Structures

A structure is a ColdFusion datatype that allows you to store and manipulate key/value pairs. Structures are similar to one-dimensional arrays, except each element is referenced via an alphanumeric “key” (string) as opposed to a numeric index within the array. Structures are also commonly known as associative arrays or hashes. Structures offer an advantage over arrays in certain situations, by allowing you to reference groups of related information by key as opposed to by numeric index. Structures are useful for storing sets of related data in a single variable. For example, you can easily store an employee’s contact information in a structure called Employee. That structure can contain keys such as Name, Address, City, State, and Zip. Additionally, a number of ColdFusion variable scopes are accessible as structures. For example, you can access all form variables available to a page by referencing a structure named Form. A similar structure is also available for several other variable scopes.

Creating a Structure

Structures are created using the StructNew( ) function. Unlike with arrays, you don’t have to pass any information to this function. To create a new structure called Stock, you use the following code:

<CFSET Stock = StructNew(  )>

Just like arrays, structures can also be created using the CFPARAM tag:

<CFPARAM NAME="Stock" TYPE="Struct" DEFAULT="#StructNew(  )#">

Be sure to wrap the StructNew( ) function with hash marks to avoid having ColdFusion treat the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Programming ColdFusion MX, 2nd Edition

Programming ColdFusion MX, 2nd Edition

Rob Brooks-Bilson

Publisher Resources

ISBN: 1565926986Catalog PageErrata