ColdFusion Programming/data structures

Lists
The truth is that in Coldfusion a list is nothing more than a string separated by a delimiter. The default delimiter is a comma. Any delimiter can be used though.For example, ColdFusion Lists:ColdFusion Arrays:ColdFusion Structures is no less a list than the comma delimited list.

Creating a list  Output: IL,MO,IA,MN
 * 1) newlist#

Changing a list

LISTAPPEND

Note that these functions do not change the original list but rather their return value is the modified list that must be set to a variable which can be the same one that you began with.  Output: IL,MO,IA,MN,IN
 * 1) newlist#

LISTGETAT Output: MN
 * 1) ListGetAt(newlist, 4)#

LISTLEN Output: 5
 * 1) ListLen(newlist)#

LISTSETAT  Output: IL,MO,HI,MN,IN
 * 1) newlist#

LISTINSERTAT  Output: IL,MO,AL,HI,MN,IN
 * 1) newlist#

LISTDELETEAT  Output: IL,MO,AL,MN,IN
 * 1) newlist#

LISTSORT  Output: AL,IL,IN,MN,MO
 * 1) newlist#

Arrays
ColdFusion Arrays are very different than lists and provide many more utilities for manipulation. Arrays are collections of objects all linked together front-to-back.

To create an array, do the following:



There are many functions to manipulate Arrays. For instance, to add an item to myArray you may use the function ArrayAppend.



Structures
ColdFusion structures are similar in many regards to other programming languages.

  

Queries
In ColdFusion Queries are a datatype.



CFDUMP
When working with structures one of the most powerful tools available to you to help debug and solve programming issues is the Cfdump tag. The Cfdump tag allows you to visually display any variable regardless of its structure type even when you have nested structures.

 where mystruct is the name of the variable to be displayed. Take note that mystruct is surrounded by pound signs. This tag does not take the name of the variable but rather the variable itself. So if we create code like:  the output would be the string: mystruct not the values within mystruct.