MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 272

Table of Contents

Advertisement

252
Each function has a built-in
function: the required arguments specified by the function parameters followed by
any additional arguments included in the function call.
The function can determine the number of arguments passed to it by using the
ColdFusion function call
The function must retrieve the optional arguments by using the
example, if the following function:
function MyFunction(MyArg1, MyArg2)
has three optional arguments, you can refer to the first two, required, arguments as
MyArg1
third and fourth and fifth, optional, arguments as
and
However, you must be careful if you mix references to the same argument using both
its parameter name and its place in the
read the argument. If you write the argument, you should consistently use either the
parameter name or the Arguments array.
Passing arguments
ColdFusion passes arrays and simple data types including integers, strings, and time
and date values into the function by value. It passes queries and structures into the
function by reference. As a result, if you change the value of a query or structure
argument variable in the function, it changes the value of the variable that the calling
page used in calling the function. However, if you change the value of an array or
string argument variable in the function, it does not change the value of the string
variable in the calling page.
Using variables
A function can access all variables that are available in the calling page. In addition,
the function has its own private scope that contains the function parameters, the
Arguments
the current instance of the function. As soon as the function exits, all the variables
are removed.
A function can use and change any variable that is available in the calling page,
including variables in the caller's Variables (local) scope, as if the function were part
of the calling page. For example, if you know that the calling page has a local variable
called Customer_name (and there is no
function can read and change the variable by referring to it as "Customer_name" or
(using better coding practice) "Variables.Customer_name".
Similarly, you can create a local variable inside a function and then refer to it
anywhere in the calling page after the function call. You cannot refer to the variable
before you call the function.
Because function
function executes, function variable names can be independent of variable names
Chapter 13 Extending ColdFusion Pages with CFML Scripting
and
or as
MyArg2
Arguments[5].
array, and the
variables do not take a scope identifier and exist only while the
var
array containing all arguments passed to the
Arguments
ArrayLen(Arguments)
and
Arguments[1]
Arguments[2]
Arguments
-declared variables. This scope is only accessible inside
var
variable named Customer_name) the
var
.
Arguments
. You must refer to the
,
Arguments[3]
Arguments[4],
array. Mixing is fine if all you do is
array. For

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents