Using CFDUMP


Using CFDUMP

Before we get into our discussion about complex data types, we need to discuss a tool that will help you verify each test that will be run. That tool is ColdFusion's CFDUMP tag.

CFDUMP was added to ColdFusion with the release of version 5. It quickly became the best friend of many ColdFusion developers. CFDUMP was migrated into the ColdFusion tag set from Spectra, where it was known as CFA_DUMP.

CFDUMP displays the contents of both simple and complex variables. With CFDUMP, you can view the contents of a query object, a list, an array, a structure, or a Web Distributed Data eXchange (WDDX) packet. You can even access memory structures, such as the session, application, server, cookie, common gateway interface (CGI), form, and request scopes.

CFDUMP displays the values of these simple and complex data types in a table formatted in Hypertext Markup Language (HTML). Different data types have their own color borders. All structures have a blue border, while all query objects have a red border. See Table 7.1 for more information.

Table 7.1. Data Types and Their Corresponding Color Borders

Data Type

Color

Array

Green border

Array index

Light-green background

Binary/ColdFusion object

Yellow border, light-yellow background

Query

Red border

Query object column name

Light-red background

Structure

Blue border

Structure key

Light-blue background

User-defined function

Light beige

WDDX-encoded data

Black border

CFDUMP is a tag that is an indispensable tool for code debugging. You simply call the CFDUMP tag within your template and the resulting data is displayed. The syntax for this tag is the following:

 <cfdump var="#variablename#"> 

CFDUMP is often used in conjunction with the CFABORT tag to stop the processing of a template right after the CFDUMP tag call:

 <cfdump var="#variablename#"><cfabort> 

Let's look at the tag in real code, as in Listing 7.1.

Listing 7.1 Using CFDUMP to Access the Server Memory Structure Values
 These are the contents of my server memory structure:<br>                           <br>                           <cfdump var="#server#"> 

The resulting output might look something like Figure 7.1:

Figure 7.1. The output can be contracted by clicking the lighter-shaded structure key.

graphics/07fig01.gif



Inside ColdFusion MX
Inside Coldfusion MX
ISBN: 0735713049
EAN: 2147483647
Year: 2005
Pages: 579

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net