View comments | RSS feed

Calling user-defined functions

You can call a UDF in two ways:

You can use either technique for any function. However, if you use named arguments, you must use the same argument names to call the function as you use to define the function. You cannot call a function with a mixture of named and unnamed arguments. For more information on calling functions with and without argument names, see "Calling functions and using variables".

One example of a user-defined function is a TotalInterest function that calculates loan payments based on a principal amount, annual percentage, and loan duration in months (For this function's definition, see "A User-defined function example"). You might call the function without argument names on a form's action page, as follows:

<cfoutput> 
Interest: #TotalInterest(Form.Principal, Form.Percent, Form.Months)#
</cfoutput>

You might call the function with argument names, as follows:

<cfoutput> 
Interest: #TotalInterest(principal=Form.Principal, annualPercent=Form.Percent,
    months=Form.Months)#
</cfoutput>

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


kustomkat said on Mar 20, 2005 at 10:16 PM :
how do you call a function defined using cffunction that contains a
query? Not something you want to put into a cfoutput tag. ARGH so
frustrating. THis is such a basic thing why don't th edocs cover this in a
simple example.
jrunrandy said on Mar 29, 2005 at 1:28 PM :
I think that the discussion on http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/UDFs7.htm might be what you are looking for.

Also, are you really using version 6 (ColdFusion MX). The most current versions are 6.1 and 7. For more information on docs for those versions, see http://livedocs.macromedia.com/coldfusion/

 

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/UDFs3.htm