Creating Client and Cookie variables with periods
To create a Client or Cookie variable with a name that includes one or more periods, simply
assign the variable a value. For example, the following line creates a Cookie named
User.Preferences.CreditCard:
<cfset Cookie.User.Preferences.CreditCard="Discover">
Data type conversion
ColdFusion automatically converts between data types to satisfy the requirements of an
expression's operations, including a function's argument requirements. As a result, you generally
don't need to be concerned about compatibility between data types and the conversions from one
data type to another. However, understanding how ColdFusion evaluates data values and converts
data between types can help you prevent errors and create code more effectively.
Operation-driven evaluation
Conventional programming languages enforce strict rules about mixing objects of different types
in expressions. For example, in a language such as C++ or Basic, the expression
produces an error because the multiplication operator requires two numerical operands and "8" is
a string. When you program in such languages, you must convert between data types to ensure
error-free program execution. For example, the previous expression might have to be written as
(ToNumber("8") * 10)
In ColdFusion, however, the expression
generating an error. When ColdFusion processes the multiplication operator, it automatically
attempts to convert its operands to numbers. Since "8" can be successfully converted to the
number 8, the expression evaluates to 80.
ColdFusion processes expressions and functions in the following sequence:
For each operator in an expression, it determines the required operands. (For example, the
1
multiplication operator requires numeric operands and the CONTAINS operator requires
string operands.)
For functions, it determines the type required for each function argument. (For example, the
function requires two numbers as arguments and the
Min
It evaluates all operands or function arguments.
2
It converts all operands or arguments whose types differ from the required type. If a conversion
3
fails, it reports an error.
Conversion between types
Although the expression evaluation mechanism in ColdFusion is very powerful, it cannot
automatically convert all data. For example, the expression
because ColdFusion cannot convert the string "eight" to the number 8. Therefore, you must
understand the rules for conversion between data types.
.
("8" * 10)
evaluates to the number 80 without
function requires a string.)
Len
produces an error
"eight" * 10
Data type conversion
("8" * 10)
67
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers