
121
DEVELOPING
COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Las
t
upda
te
d 8/5/2010
Example
public String foo(array a)
{
for(var item in a)
{
writedump(item);
}
}
var declaration within for loop
Note:
This feature applies only if you have installed ColdFusion 9 Update 1.
You can use
var
inline with for-in construct to bind variable to the local scope for both structs and arrays.
Example
public String foo(struct s)
{
for(var item in s)
{
writedump(item & ": " & s[item]);
}
writedump(local);
}
For arrays example, see “
for-in construct (for arrays)
” on page 120.
Defining components and functions in CFScript
ColdFusion supports the syntax for defining CFCs, including interfaces, functions, properties, and parameters entirely
in CFScript. Currently, however, only certain ColdFusion tags are supported as CFScript functions. This section
describes the component definition syntax.
For information on tags as functions see “
Tag equivalents in CFScript
” on page 109.
Basic Syntax
Syntax for defining a component is as follows:
/**
* ColdFusion treats plain comment text as a hint.
* You can also use the @hint metadata name for hints.
* Set metadata, including, optionally, attributes, (including custom
* attributes) in the last entries in the comment block, as follows:
*@metadataName metadataValue
...
*/
component attributeName="attributeValue" ... {
body contents
}
The following example shows a simple component definition