In addition to all of the new features planned for ColdFusion Centaur, and the introduction of the new ColdFusion IDE, we’ve also managed to sneak in lots of smaller CFML enhancements, some of which are long overdue. Here are some of what we’ve been working on.
-
Assignments can now be chained, so this will work:
-
Ternary operators are now supported:
-
In ColdFusion 8 we allowed you to create structures and arrays implicitly, like this:
The problem is that we didn’t quite finish the implementation, and so if you wanted to pass that structure to a tag or function you’d have needed to first save it to a temporary variable, like this:
This has been fixed in Cenatur, and the following will now work (as it should have before):
-
A new
tag has been added, to complement the existing continue CFSCRIPT operator.
-
Support for “finally” has been added via a
tag and a finally operator.
- One of the biggest CFML enhancement is in CFSCRIPT which now supports all of CFML (with minor exceptions where not appropriate). You can now build CFCs entirely in CFSCRIPT, including Application.cfc. You can invoke any tags and functions in CFSCRIPT. You can use new operators like abort, exit, include, and throw, to simplify your CFSCRIPT. In fact, you can now build a complete ColdFusion application entirely in CFSCRIPT, without using any CFML, if you are so inclined.
-
To make the CFSCRIPT enhancements work properly, we’ve also added a few new functions, WriteDump() is the equivalent of
, WriteLog()is the equivalent of (both of these are named similarly to the existing WriteOutput() function), Trace() is the equivalent of , Location() is the equivalent of , and Throw() is the equivalent of .
- ColdFusion variables (including complex types like arrays, structures, queries, CFCs, and Java objects) can be serialized to binary objects using the new SaveCFObject() function, and then deserialized later as needed using LoadCFObject(). These functions can work with variables as well as files, so objects can be serialized to disk and then read later when needed.
And we’re not done yet. Stay tuned, more cool stuff to follow!
The ternary operator makes me smile, Ben.
Seconded about the ternary operator. I know the other changes are awesome, too, but I’ve been whining for a ternary operator for 10+ years.
So what have these guys been doing with all the spare time they have on their hands Ben?
Do you think a CFSCRIPT version of CFQUERY will makes it way in?
Jared, yes, it will.
— Ben
I am interested in seeing an application.cfc written entirely in cfscript.
Awesome! Now if only a release date would be announced so that we can plan our overhaul w/ ORM integration accordingly…. We’re putting off the integration of Hibernate until CF9 comes out to prevent having to go backwards….
Its great to see these subtleties being included in the new release along with important features like <cffinally>.
This may not sit with others but I would like to see a new file extension for CFSCRIPT only files. Instead of having to use the CFSCRIPT tags to open and close the file, just name the file FILENAME.CFS or something like that. Not a major thing, just something I was thinking about.
Russ, way back in CF5 days we talked about a CFS file, a file which was all CFSCRIPT and did not need the <CFSCRIPT> </CFSCRIPT> tags. Would be a bit trickier now, as we’d need two of those, one for .CFM files and one for .CFC files. But, still a worthy idea for a future enhancement.
— Ben
Thanks for the updates. What will the CFSCRIPT version of <cfquery /> look like?
"You can invoke any tags and functions in CFSCRIPT."
Will that include the ability to invoke custom tags in CFSCRIPT?
Are there plans to skip the "save to a variable" step for functions that return queries/arrarys?
For example:
<cfoutput query="returnsAQuery()"></cfoutput>
Instead of the current way:
<cfset myQuery = returnsAQuery() />
<cfoutput query="myQuery"></cfoutput>
Hi, Ben, still looking for something on SharePoint integration. It would be great to be able to read a SP entry (or a set, possibly a date range) out of SP instead of having to export SP records. Thanks.
Russ, For CFCs that are written in cfscript style, you do not need to write <cfscript>. You just write it in the cfscript syntax.
I can’t wait for SaveCFObject()!!!
can you comment on any updates regarding exchange (availability of last datetime update of a record) and Sharepoint integration.
Thanks
Marius
>>and Throw() is the equivalent of <CFTHROW>
So why not Dump() and Output(), etc? Why the verbose addition of "write"?
Hi Sean, custom tags are not supported in CFSCRIPT. Also, not all tags can be used in cfscript. We have added script support for most of the frequently used tags – cfquery, cftransaction, cflock, cfmail, cfthread, components, functions, cfthrow, cfrethrow, cffinally, cfexit, etc. Please refer the documentation for the whole list of attributes.
Some of the tags for which script syntax is not supported – cfpop, cfimap, UI tags like cfgrid, etc.
@MJ, thanx for the clarification. I’m just looking at the CF9 Public Beta docs now to see what you guys decided to support in the end. Great work!
Does anyone know if there is support for connecting to more than one datasource in the CF9 ORM? I just read through the beta docs and I don’t see a way mentioned.
Hi Randy, ColdFusion-ORM does not support multiple datasources. ColdFusion-ORM is designed to work with one datasource only, which you configure in Application.cfc (this.ormsettings.datasource=<datasourcename>).
So then, if my application has multiple datasources then I cannot use the new ORM in CF9?
There had been a lot of discussions around supporting multiple datasources in Coldfusion-ORM all through the release. We had to make a trade-off between design-simplicity and supporting-multiple-datasources-per-application. We took the approach of keeping the design simple by supporting one-datasource-per-application. For applications which use multiple datasources, you could use the ORM approach for the primary datasource and revert back to the cfquery-based approach for the other datasources. Of-course let us know if you think otherwise.
I was just looking at the cf9 docs and didn’t see any new functions for creating queries, nor is there one for creating new threads. Is the documentation 100% up to date, or is ORM the only way to access the DB via cfscript?
@manjukiran,
I appreciate the info. And I will admit that there is a lot to like and look forward to about CF9. And the ORM looks very promising. However, using an ORM for part of the data access is not a good idea. The benefit of medium to large proje
I’ve written a complete Application.cfc reference in CFScript for Coldfusion 9. You can see it here: http://cfruss.blogspot.com/2009/11/applicationcfc-reference-in-cfscript.html
It includes all available methods and variables, and is fully commented.
Forgot to include the link to my Application.cfc reference: http://cfruss.blogspot.com/2009/11/applicationcfc-reference-in-cfscript.html