| Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > Creating user-defined functions > Defining functions in CFScript CFScript function definition syntax |
|
|
|
|
||
A CFScript function definition has the following syntax:
functionfunctionName([argName1[,argName2...]])
{
CFScript Statements
}
The following table describes the function variables:
Function variable |
Description |
|---|---|
functionName |
The name of the function. You cannot use the name of a standard ColdFusion function or any name that starts with "cf". You cannot use the same name for two different function definitions. Function names cannot include periods. |
argName1... |
Names of the arguments required by the function. The number of arguments passed into the function must equal or exceed the number of arguments in the parentheses at the start of the function definition. If the calling page omits any of the required arguments, ColdFusion generates a mismatched argument count error. |
The body of the function definition must consist of one or more valid CFScript statements. The body must be in curly braces, even if it is a single statement.
The following two statements are allowed only in function definitions:
Statement |
Description |
|---|---|
|
Creates and initializes a variable that is local to the function (function variable). This variable has meaning only inside the function and is not saved between calls to the function. It has precedence in the function body over any variables with the same name that exist in any other scopes. You never prefix a function variable with a scope identifier, and the name cannot include periods. The initial value of the variable is the result of evaluating the expression. The expression can be any valid ColdFusion expression, including a constant or even another UDF. All var statements must be at the top of the function declaration, before any other statements. You must initialize all variables when you declare them. You cannot use the same name for a function variable and an argument. Each var statement can initialize only one variable. You should use the var statement to initialize all function-only variables, including loop counters and temporary variables. |
|
Evaluates expression (which can be a variable), returns its value to the page that called the function, and exits the function. You can return any ColdFusion variable type. |
|
|
||
| Contents > Developing ColdFusion MX Applications > Writing and Calling User-Defined Functions > Creating user-defined functions > Defining functions in CFScript CFScript function definition syntax |
|
|
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.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/udfs12.htm
Comments
toniu27 said on Jun 21, 2004 at 9:57 AM :