The values created within a ColdFusion script are accessible within a template, just as are values created with CFSET.
For instance, in the following template, the variable created within the script block is later accessible within the CFOUTPUTtag:
myText – ‘Kello’;
The most important issue with scripts is that no direct way exists to generate output to the browser. However, the WriteOutput function can generate output to the browser. This function takes a string as a value. Therefore, the preceding code segment can all be executed from within a script:
Where Do We Go from Here?
Up to this point in the book, you have worked with templates that require a user to request them with their browser for them to execute. However, many features of ColdFusion would be more useful if they could automatically be executed on a schedule. For instance, a template could be written that doesn’t generate any HTML output for a browser but that rather executes a query and generates an e-mail report based on the query results.
Fortunately, Cold Fusion offers a scheduling feature that enables templates to bescheduled for automatic execution. In the next chapter you will learn to use the ColdFusion scheduling capability, both through the ColdFusion Administrator and by using the CFSCHEDULE tag. You will also learn about the special aspects of developing templates for automatic execution.