About conditional processing
27
String operator
The following table describes the one ColdFusion string operator that is a concatenation
operator:
About conditional processing
So far, all the coding examples shown in this chapter are considered linear coding examples.
Linear code
is when ColdFusion executes code starting with the first line on the page, and
processes every line in order. Although you will use linear code in your applications, you will
often write code that performs various actions based on conditions, such as the following:
•
Determine whether a user entered a value in a form field.
•
Display results based on user input.
•
Display messages based on the time of day.
You use conditional processing to customize the behavior of your application.
Conditional
processing
facilitates decision making and lets you control how the code on a page is processed.
In ColdFusion, you implement conditional processing with flow control tags. These tags are
similar to other programming language control elements, such as
if
,
then
, and
else
. When
using these tags, you can facilitate decision making in your code. The most fundamental tags used
to control code execution are the
cfif
,
cfelse
, and
cfelseif
tags. Because you will see and use
these tags in Part II of this manual, the following sections provide a basic introduction on how to
use these tags. For more information about other conditional processing tags, including tags for
looping, see
ColdFusion MX Developer’s Guide
.
Using the cfif tag to evaluate True or False conditions
To create statements that let you evaluate conditions and perform an action based on the result,
you use the
cfif
tag to create a
cfif
statement. The basic syntax is as follows:
<cfif
expression
>
HTML and CFML tags executed if expression is True.
</cfif>
In this example, ColdFusion only executes the code inside the
cfif
statement if the expression
evaluates to True. To perform actions if the expression is False, you can use the
cfelse
tag. For
example, if the following
cfif
expression evaluates to False, the code between the
cfels
e tag and
the ending
cfif
tag is processed:
<cfif
expression
>
HTML and CFML tags executed if expression is True.
<cfelse>
HTML and CFML tags executed if expression is False.
</cfif>
Operator
Description
&
Concatenates strings.
Summary of Contents for COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION...
Page 1: ...COLDFUSION MX7 Getting Started Building ColdFusion MX Applications...
Page 6: ...6 Contents...
Page 10: ......
Page 14: ...14 Chapter 1 Introducing ColdFusion MX...
Page 38: ...38 Chapter 3 Database Fundamentals...
Page 40: ......
Page 58: ...58 Chapter 5 Lesson 2 Configuring Your Development Environment...
Page 70: ...70 Chapter 6 Lesson 3 Retrieving Data...
Page 84: ...84 Chapter 7 Lesson 4 Building Dynamic Queries...
Page 96: ...96 Chapter 8 Lesson 5 Creating a Trip Detail Page...
Page 102: ...102 Chapter 9 Lesson 6 Creating a Main Application Page...