CF 8 New Features – cfloop enhancements!
Isn’t that simple yet powerful? My next post would talk about the new rocking tag – cfthread.
I plan to introduce the new features of Coldfusion 8. To start it off, here are the enhancements to cfloop. The simple-to-use cfloop has just got richer. Now, you can loop through files and arrays using cfloop!
<html><head><title>CFLoop over a file</title></head>
<cfset fileName = ExpandPath('./') & "tempFile.txt"><cfif fileExists(fileName)><cfset fileDelete(fileName)></cfif>
<cfset fileObj = FileOpen(fileName,"Append")><cfloop from="1" to="10" index="i"><cfset content = "Line Number " & i><cfset FileWriteLine(fileObj, content)></cfloop>
<cfset i = 0><---If you want to read 'caracters' instead of 'lines', use the "characters" attribute!---><cfloop file="#fileName#" index="line"><cfoutput>#line#<br></cfoutput><cfset i++></cfloop><cfoutput>#i# lines of code were read<br></cfoutput>
<cfdump var="#getFileInfo(fileName)#">
<cfset FileClose(fileObj)>
<cfset adbeStruct = {quoteName="adbe", price="43.01"}><cfset msftStruct = {quoteName="msft", price="30.3"}><cfset googStruct = {quoteName="goog", price="513.5"}><cfset yhooStruct = {quoteName="yhoo", price="53.1"}><cfset aaplStruct = {quoteName="aapl", price="115.4"}>
<cfset arr1 = [adbeStruct, msftStruct, googStruct, yhooStruct, aaplStruct]>
<cfloop array=#arr1# index="quoteData"> <cfoutput> <table width=25% border=1> <tr> <td width=75%>#quoteData.quoteName#</td> <td width=25%>#quoteData.price#</td> </tr> </table> </cfoutput></cfloop>



Recent Comments