CodFusion 8 adds three new attributes (characters, file, and array) to the CFloop tag that make it a little easier to loop through the contents of files and arrays. The array attribute is pretty cool, but the file/characters attributes are really exciting for me. In previous versions of ColdFusion, to loop through an array you would create the loop to basically count from 1 to the length of the array, then access each item in the array within the loop like:
ColdFusion 8 makes array looping a little simpler, you can specify the array attribute and the index variable will hold the contents of each array item.
Looping through the contents of a text file is something I have done often, particularly when developing data integration processes between my ColdFusion applications and other systems. For example, if you were importing records from a CSV file in to a table, to loop through the lines of a file you used to have to read the file and convert the lines to an array, then loop through the array of lines, like this:
Now you can do the same thing by just pointing the cfloop to the file like this:
If you are importing data from a file with fixed field lengths that doesn't use line feeds or carriage returns, you can use the "characters" attribute to tell the CFloop when how long each record is and it will us that instead of reading each line. For example if each record in your file consists of 30 characters, then you could loop through the records like this:
Overall, I think the new ability to loop through the contents of a file in ColdFusion 8 is pretty slick, and I wish they would have done this sooner. I can't even tell you how many times I have seen the "how do I loop through a files lines?" question asked on various ColdFusion forums.
I know, nit-picky, but in your last example, shouldn't index="FileRecord" be index="FileLine"?