View comments | RSS feed

Calling user-defined functions

User-defined functions (UDFs) let you create application elements in a format in which you pass in arguments and get a return a value. You can define UDFs using CFScript or the cffunction tag. The two techniques have several differences, of which the following are the most important:

You use UDFs in your application pages as you use standard ColdFusion functions. You can create a function for an algorithm or procedure that you use frequently, and then use the function wherever you need the procedure.

As with custom tags, you can easily distribute UDFs to others. For example, the Common Function Library Project at http://www.cflib.org is an open-source collection of CFML user-defined functions.

Calling UDFs

To call a UDF, use it as you would a ColdFusion built-in function. For example, the following line calls the function MyFunct and passes it two arguments:

<cfset returnValue=MyFunct(Arg1, Arg2)>

Recommended uses

Typical uses of UDFs include, but are not limited to, the following:

Consider using UDFs in the following circumstances:

If you can create either a UDF or a custom CFML tag for a particular purpose, first consider creating a UDF because invoking it requires less system overhead than using a custom tag.

For more information

For more information on user-defined functions, see Chapter 9, "Writing and Calling User-Defined Functions".

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


carehart@systemanage said on Jan 3, 2003 at 9:53 AM :
Regarding the statement:

"If you can create either a UDF or a custom CFML tag for a particular purpose, first consider creating a UDF because invoking it requires less system overhead than using a custom tag."

While that was conventional wisdom in CF 5, hasn't it been demonstrated that there is neglible performance difference between UDFs and custom tags (and CFINCLUDE, yadda yadda yadda) in CFMX?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/reuseIntro4.htm