Writing And Calling User-Defined Functions - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Purpose
Use variables with names that change from use
to use.
Provide accessibility from Flash clients.
Use built-in user security features.
Encapsulate multiple related functions and
properties.
Create web services.
Implement object-oriented coding
methodologies.

Writing and Calling User-Defined Functions

Creating custom functions for algorithms or procedures that you call frequently lets you organize and reuse the
functions in your Adobe ColdFusion application pages.
About user-defined functions
You can create your own custom functions, known as user-defined functions, or UDFs. You then use them in your
application pages the same way you use standard ColdFusion functions. You can also organize functions you create by
grouping related functions into ColdFusion components. For more information, see
Components" on page 177.
When you create a function for an algorithm or procedure that you use frequently, you can then use the function
wherever you require 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 number (#) signs in
output, and in CFScript code. Typical uses of UDFs include, but are not limited to the following:
• Data manipulation routines, such as a function to reverse an array
• String and date/time routines, such as a function to determine whether a string is a valid IP address
• Mathematical calculation routines, including standard trigonometric and statistical operations or calculating loan
amortization
• Routines that call functions externally, for example using COM or CORBA, including routines to determine the
space available on a Windows file system drive
For information about selecting among user-defined functions, ColdFusion components, and custom tags, see
"Creating ColdFusion
Elements" on page 146.
Note: The Common Function Library Project at
functions.
Creating user-defined functions
Before you create a UDF, determine where you want to define it, and whether you want to use CFML or CFScript to
create it.
cfinclude tag
Custom tag
A
A
www.cflib.org
is an open source collection of CFML user-defined
Last updated 1/20/2012
UDF
Component
P
P
A
P
A
P
P
P
P
"Building and Using ColdFusion
153

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents