You can create user-defined functions, or UDFs (also known as custom functions), and use them in your application pages as you do standard ColdFusion functions. This lets you create a function for an algorithm or procedure that you use frequently, and then use the function wherever you need the procedure. If you must change the procedure, you change only one piece of code. You can use your function anywhere that you can use a ColdFusion expression: in tag attributes, between pound (#) signs in output, and in CFScript code. Typical uses of UDFs include, but are not limited to the following:
For information about selecting among User-defined functions, custom tags, and ColdFusion components, see Chapter 8, "Reusing Code in ColdFusion Pages".
Note: The Common Function Library Project at http://www.cflib.org is an open source collection of CFML user-defined functions.
To use a user-defined function, you define the function and then call it. Typically you define the function on your ColdFusion page or a page that you include. You can also define the function on one page and put it in a scope that is shared with the page that calls it. (For more information on UDF scoping, see "Specifying the scope of a function".) You can also put commonly used functions on a single ColdFusion page and include it in your Application.cfm page.