Creating a Function Library - Exercise

Contact Us or call 1-877-932-8228
Creating a Function Library - Exercise

Creating a Function Library

Duration: 5 to 10 minutes.

In this exercise, you will move the function you created in the last exercise into a function library and then include that library in RunningLog2.cfm with <cfinclude>.

  1. Open ReusingCode/Exercises/RunningLog.cfm in your editor and save it as RunningLog2.cfm.
  2. Cut the File2Table function and paste it in a new file. Save the new files as Functions.cfm.
  3. Add code to RunningLog2.cfm so that it includes the new function library.


               <cfinclude template="Functions.cfm">
  <title>Running Log</title>
<h1>Running Log</h1>
<a href="AddEntry.cfm">Add Entry</a><hr/>
<cfset arrHeaders = ArrayNew(1)>
<cfset ArrayAppend(arrHeaders,"Date")>
<cfset ArrayAppend(arrHeaders,"Distance")>
<cfset ArrayAppend(arrHeaders,"Time")>
<cfset ArrayAppend(arrHeaders,"Comments")>