23.08.2013 Views

ColdFusion Developer's Guide - Electromanuals.org

ColdFusion Developer's Guide - Electromanuals.org

ColdFusion Developer's Guide - Electromanuals.org

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Ofrecido por www.electromanuales.com<br />

<br />

<br />

<br />

My.Variable.With.Periods is: #My.Variable.With.Periods#<br />

Request.Another.Variable.With.Periods is:<br />

#Request.Another.Variable.With.Periods#<br />

<br />

ADOBE COLDFUSION 8<br />

<strong>ColdFusion</strong> Developer’s <strong>Guide</strong><br />

Creating Client and Cookie variables with periods<br />

To create a Client or Cookie variable with a name that includes one or more periods, simply assign the variable a<br />

value. For example, the following line creates a Cookie named User.Preferences.CreditCard:<br />

<br />

Data type conversion<br />

<strong>ColdFusion</strong> automatically converts between data types to satisfy the requirements of an expression’s operations,<br />

including a function’s argument requirements. As a result, you generally don’t need to be concerned about compatibility<br />

between data types and the conversions from one data type to another. However, understanding how<br />

<strong>ColdFusion</strong> evaluates data values and converts data between types can help you prevent errors and create code more<br />

effectively.<br />

Operation-driven evaluation<br />

Conventional programming languages enforce strict rules about mixing objects of different types in expressions. For<br />

example, in a language such as C++ or Basic, the expression ("8" * 10) produces an error because the multiplication<br />

operator requires two numerical operands and "8" is a string. When you program in such languages, you must<br />

convert between data types to ensure error-free program execution. For example, the previous expression might have<br />

to be written as (ToNumber("8") * 10).<br />

In <strong>ColdFusion</strong>, however, the expression ("8" * 10) evaluates to the number 80 without generating an error. When<br />

<strong>ColdFusion</strong> processes the multiplication operator, it automatically attempts to convert its operands to numbers.<br />

Since "8" can be successfully converted to the number 8, the expression evaluates to 80.<br />

<strong>ColdFusion</strong> processes expressions and functions in the following sequence:<br />

1 For each operator in an expression, it determines the required operands. (For example, the multiplication<br />

operator requires numeric operands and the CONTAINS operator requires string operands.)<br />

For functions, it determines the type required for each function argument. (For example, the Min function<br />

requires two numbers as arguments and the Len function requires a string.)<br />

2 It evaluates all operands or function arguments.<br />

3 It converts all operands or arguments whose types differ from the required type. If a conversion fails, it reports<br />

an error.<br />

Conversion between types<br />

Although the expression evaluation mechanism in <strong>ColdFusion</strong> is very powerful, it cannot automatically convert all<br />

data. For example, the expression "eight" * 10 produces an error because <strong>ColdFusion</strong> cannot convert the string<br />

"eight" to the number 8. Therefore, you must understand the rules for conversion between data types.<br />

37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!