Using Udfs Effectively; Using Application.cfm And Function Include Files; Specifying The Scope Of A Function - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Using UDFs effectively

This section provides information that will help you use user-defined functions more effectively.

Using Application.cfm and function include files

Consider the following techniques for making your functions available to your ColdFusion pages:
If you consistently call a small number of UDFs, consider putting their definitions on the
Application.cfm page.
If you call UDFs in only a few of your application pages, do not include their definitions in
Application.cfm.
If you use many UDFs, put their definitions on one or more ColdFusion pages that contain
only UDFs. You can include the UDF definition page in any page that calls the UDFs.
The next section describes other techniques for making UDFs available to your ColdFusion
pages.

Specifying the scope of a function

User-defined function names are essentially ColdFusion variables. ColdFusion variables are names
for data. Function names are names (references) for segments of CFML code. Therefore, like
variables, functions belong to scopes.
About functions and scopes
Like ColdFusion variables, UDFs exist in a scope:
When you define a UDF, ColdFusion puts it in the Variables scope.
You can assign a UDF to a scope the same way you assign a variable to a scope, by assigning the
function to a name in the new scope. For example, the following line assigns the MyFunc UDF
to the Request scope:
<cfset Request.MyFunc = Variables.MyFunc>
You can now use the function from any page in the Request scope by calling Request.MyFunc.
206
Chapter 10: Writing and Calling User-Defined Functions

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