MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 195

Developing coldfusion mx applications
Table of Contents

Advertisement

The following sections describe the general rules for using the Arguments scope as an array and a
structure. For more information on using the Arguments scope in functions defined using
CFScript, see
"Using the Arguments scope in CFScript" on page
using the Arguments scope in functions defined using the
Arguments scope in cffunction definitions" on page
The contents of the Arguments scope
The following rules apply to the Arguments scope and its contents:
The scope contains all the arguments passed into a function.
If you use
cffunction
each declared argument, even if you do not pass the argument to the function when you call it.
If you do not pass a declared (optional) argument, the scope entry for that argument is empty.
When you call a function that you defined using CFScript, you must pass the function a value
for each argument declared in the function definition. Therefore, the Arguments scope for a
CFScript call does not have empty slots.
The following example shows these rules. Assume that you have a function declared, as follows:
<cffunction name="TestFunction">
<cfargument name="Arg1" >
<cfargument name="Arg2">
</cffunction>
You can call this function with a single argument, as in the following line:
<cfset TestFunction(1)>
The resulting Arguments scope looks like the following:
As an array
Entry
Value
1
1
2
undefined
In this example, the following functions return the value 2 because there are two defined
arguments:
ArrayLen(Arguments)
StructCount(Arguments)
However, the following tests return the value False, because the contents of the second element in
the Arguments scope is undefined.
Isdefined("Arguments.Arg2")
testArg2 = Arguments[2]>
Isdefined("testArg2")
Note: The
IsDefined
that might try to access an undefined array element in a try block and use a catch block to handle
exceptions that arise if a elements do not exist.
to define the function, the scope always contains an entry "slot" for
As a structure
Entry
Arg1
Arg2
function does not test the existence of array elements. Instead, put any code
199. For more information on
tag, see
cffunction
202.
Value
1
undefined
Creating user-defined functions
"Using the
195

Advertisement

Table of Contents
loading
Need help?

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

This manual is also suitable for:

Coldfusion mx

Table of Contents