Functions as Operators

Functions are a form of operator. Because ColdFusion functions return basic objects, such as numbers, strings, Boolean values, date-and-time objects, lists, arrays, structures, queries, and COM objects, function results can be used as operands.

The following sections describe:

Function syntax

The following table shows function syntax and usage guidelines.
Usage
Example
No arguments

Function() 

Basic format

Function(Data) 

Nested functions

Function1(Function2(Data)) 

Multiple arguments

Function(data1, data2, data3) 

String arguments

Function('This is a demo') 

Function("This is a demo") 

Arguments that are expressions

Function1(X*Y, Function2("Text")) 

For more information on how to insert functions in expressions, see "Pound Signs".

Optional function arguments

Functions can take optional arguments after their required arguments. If omitted, all optional arguments default to a predefined value. For example:

Replace("FooFoo", "Foo", "Boo") returns "BooFoo"

Replace("FooFoo", "Foo", "Boo", "ALL") returns "BooBoo"

The difference in the results is because the Replace function takes an optional fourth argument that specifies the scope of replacement. The default value is "ONE" which explains why only the first occurrence of "Foo" was replaced with "Boo". In the second example, a fourth argument causes the function to replace all occurrences of "Foo" with "Boo".



Banner.Novgorod.Ru