Chapter 18. Scripting
When Allaire released ColdFusion 4.0, they introduced a new server-side scripting language called CFScript. CFScript is similar in appearance to JavaScript and allows you to write sections of code in your templates using a more concise format than tag-based CFML. CFScript isn’t meant to replace the CFML language; it just provides you with a choice for coding your pages. Additionally, with the introduction of ColdFusion 5.0, CFScript includes the ability to create user-defined functions. Those used to programming in JavaScript will find the CFScript constructs quite familiar.
This chapter covers everything you need to know about the CFScript language, along with examples.
Scripting Syntax
The
<CFSCRIPT> and
</CFSCRIPT> tags are at the heart of the
CFScript language. All CFScripting in a template takes place between
these tags. There are a few general guidelines that will help you
write your CFScripts:
CFSCRIPTtag pairs can be placed anywhere in your template.More than one set of
CFSCRIPTtags can be placed in your template.CFSCRIPTtags may not be nested.Code (including variable names) placed between
CFSCRIPTtag pairs is case-insensitive.CFML tags may not be used within a
CFSCRIPTtag block.CFML functions may be used within a
CFSCRIPTblock.CFML variables created outside a
CFSCRIPTblock are automatically available within the block.Not all CFML variables created inside the
CFSCRIPTblock are automatically available outside of the block.CFScript ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access