The goal is to allow the definition of all functions of a .cfm or .cfc using scripting rather than CFML tags.
I would like to change this:
<cffunction name="foo" access="remote">
<cfscript>
....
</cfscript>
</cffunction>
Into something like this:
<cfscript>
function remote foo() {
....
}
</cfscript>
Or something else, as long as it can be done within opening and closing cfscript tags.
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.
ColdFusion Functions. A function is a self contained block of code that performs a given 'function', then returns a value. Often, a function will require that you pass it one or more arguments. The purpose of an argument is to provide the function with further info that it needs in order to process.
I will now explain how to create functions using tags (you can also create functions in ColdFusion script). Function is declared with the usage of tag <cffunction>. What is inside this tag definition is part of function body and will be executed when the function is called.
Before you can access all this data you need to connect to it. You need to tell ColdFusion server where to look for all this data. This is done through ColdFusion administrator.
Not possible in CF8, made possible in CF9:
access returnType function functionName(arg1Type arg1Name="defaultValue1" arg1Attribute="attributeValue...,arg2Type arg2Name="defaultValue2" arg2Attribute="attributeValue...,...) functionAttributeName="attributeValue" ... { body contents }
Defining components and functions in CFScript
So your function would look similar to:
<cfscript>
remote function foo() {
...
}
<cfscript>
You could also do:
function foo() access="remote" returntype="JSON" {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With