Using Custom Functions Effectively - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

254
}
</cfscript>
You could use the TotalInterest function in a
follows:
<cfoutput>
Loan amount: #Form.Principal#<br>
Annual percentage rate: #Form.AnnualPercent#<br>
Loan duration: #Form.Months# months<br>
TOTAL INTEREST: #TotalInterest(Form.Principal, Form.AnnualPercent,
Form.Months)#<br>
</cfoutput>
This function shows the use of optional arguments. It takes two or more arguments
Example 2
and adds them together.
<cfscript>
function Sum2(a,b)
{
}
</cfscript>

Using custom functions effectively

These notes provide information that will help you use custom functions more
effectively.
Using Application.cfm
Consider putting custom functions that you use frequently on the Application.cfm
page.
Queries as function parameters
When you call a custom function in the body of a tag that has a
as
single element of the column, not the entire column. Therefore, functions that
manipulate query data and are called within the bodies of ColdFusion tags with
query attributes should only manipulate one query row.
Return DollarFormat(totalInterest);
var sum = a + b;
var arg_count = ArrayLen(Arguments);
var opt_arg = 3;
for( ; opt_arg LTE arg_count; opt_arg = opt_arg + 1 )
{
sum = sum + Arguments[opt_arg];
}
return sum;
tag, a query column name parameter is normally passed as a
cfloop query=...
Chapter 13 Extending ColdFusion Pages with CFML Scripting
tag of a form's action page as
cfoutput
query
attribute, such

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents