Defining Functions Using The Cffunction Tag - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Note: Avoid referring to a required argument in the body of a function by both the argument name
and its place in the Arguments scope array or structure, as this can be confusing and makes it easier
to introduce errors.
For more information on the Arguments scope, see

Defining functions using the cffunction tag

The
cffunction
CFScript.
Note: This chapter describes how to use the
ColdFusion component. For information on ColdFusion components, see
Using ColdFusion Components," on page
CFML Reference.
The cffunction tag function definition format
A
tag function definition has the following format:
cffunction
<cffunction name="functionName" [returnType="type" roles="roleList"
access="accessType" output="Boolean"]>
<cfargument name="argumentName" [Type="type" required="Boolean"
default="defaultValue">]
.
.
Function body code
.
.
<cfreturn expression>
</cffunction>
where square brackets ([]) indicate optional arguments. You can have any number of
tags.
The
cffunction
specify other function characteristics, as described in the following table:
Attribute
Description
name
The function name.
returnType
(Optional) The type of data that the function returns. The valid standard type names
are: any, array, binary, boolean, date, guid, numeric, query, string, struct, uuid,
variableName and void. If you specify any other name ColdFusion requires the
argument to be a ColdFusion component with that name.
ColdFusion throws an error if you specify this attribute and the function tries to return
data with a type that ColdFusion cannot automatically convert to the one you
specified. For example, if the function returns the result of a numeric calculation, a
returnType attribute of string or numeric is valid, but array is not.
200
Chapter 10: Writing and Calling User-Defined Functions
and
tags let you define functions in CFML without using
cfargument
tag specifies the name you use when you call the function. You can optionally
"About the Arguments scope" on page
tag to define a function that is not part of a
cffunction
219. For more information on the
194.
Chapter 11, "Building and
cffunction
tag, see
cfargument

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents