Integrating Scripts in a Template ColdFusion Help

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:

<CFSCRIPT>
myText – ‘Kello’;
</CFSCRIPT>

<CFOUTPUT>
#myTextit
</CFOUTPUT>

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:

<CFSCRIPT>
myText- ‘Hello’;
WriteOutput(myText)i
</CFSCRIPT>

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.

Posted on November 16, 2015 in ColdFusion Scripting

Share the Story

Back to Top
Share This