| Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > A User-defined function example > Defining the function using the cffunction tag |
|
|
|
|
||
The following code replaces CFScript statements with their equivalent CFML tags.
<cffunction name="TotalInterest"><cfargument name="principal" required="Yes"><cfargument name="annualPercent" required="Yes"><cfargument name="months" required="Yes"><cfset years = 0><cfset interestRate = 0><cfset totalInterest = 0><cfset principal = trim(principal)><cfset principal = REReplace(principal,"[\$,]","","ALL")><cfset annualPercent = Replace(annualPercent,"%","","ALL")><cfset interestRate = annualPercent / 100><cfset years = months / 12><cfset totalInterest = principal*(((1+ interestRate)^years)-1)><cfreturn DollarFormat(totalInterest)></cffunction>
|
|
||
| Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > A User-defined function example > Defining the function using the cffunction tag |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.