Adobe COLDFUSION 9 Manual page 167

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
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
to define the function, the scope always contains an entry "slot" for each declared argument,
cffunction
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, 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 the scope contains two defined arguments:
ArrayLen(Arguments)
StructCount(Arguments)
However, the following tests return the value
scope is undefined.
Isdefined("Arguments.Arg2")
testArg2 = Arguments[2]>
Isdefined("testArg2")
Note: The
function does not test the existence of array elements. Use the function
IsDefined
the array elements.
Using the Arguments scope as an array
The following rules apply to referencing Arguments scope as an array:
• If you call the function using unnamed arguments, the array index is the position of the argument in the function
call.
• If you use names to pass the arguments, the array indexes correspond to the order in which the arguments are
declared in the function definition.
• If you use names to pass arguments, and do not pass all the arguments defined in the function, the Arguments array
has an empty entry at the index corresponding to the argument that was not passed. This rule applies only to
functions created using the
As a structure
Entry
Arg1
Arg2
, because the contents of the second element in the Arguments
false
tag.
cffunction
Last updated 8/5/2010
Value
1
undefined
to search
ArrayContains
162

Advertisement

Table of Contents
loading

Table of Contents