How do I reverse this list?

I have a log file of admin activity that I’m keeping, and I’m using a text file to keep the size of our sluggish Access database to a minimum. On our admin panel, I want to display the last x activities in a table. I came up with the following:


<cffile action="read" file="[path]\\action.log" variable="logfile">
<table width="800" border="0" cellspacing="0" cellpadding="5" class="cf_table">
<tr>
<th colspan="3" align="left" class="cf_lglabel cf_th">Activity Log</th>
</tr>
<tr>
<td><strong>Action</strong></td>
<td><strong>User</strong></td>
<td><strong>Time</strong></td>
</tr>
<cfloop index="index" list="#logfile#" delimiters="#chr(10)##chr(13)#">
<tr>
<cfoutput>
<td>#listgetAt(index,1, ";")#</td>
<td>#listgetAt(index,2, ";")#</td>
<td>#Dateformat(listgetAt(index,3, ";"),"dd/mm/yyyy")# #Timeformat(listgetAt(index,3, ";"),"HH:mm:ss")#</td>
</cfoutput>
</tr>
</cfloop>
</table>

This works perfectly, BUT I’d like to display the log in reverse order, with newest entries first. Any ideas on how to reverse the display order?

CFLOOP from last index entry to first, unless i am missing something ?

<CFLOOP FROM=“#ListLen(logfile)# TO=“1” INCREMENT=”-1" …

I can’t use from and to with list and delimiters, and without those latter two, I don’t know how to get each line as a semicolon-delimited list.

When I try it with from, to, index, and step, I get an error.

Ok, I came up with a different solution. I used cfhttp, then queried it.


<cfhttp
url="[path]/action.log"
method="GET"
name="logfile"
columns="action_done,user_name,action_time"
delimiter=";"
textqualifier=""
firstrowasheaders="no"
/>
<cfquery name="actionlog" dbtype="query">
SELECT    action_done
	, user_name
	, action_time
FROM logfile
ORDER BY action_time DESC
</cfquery>
<table width="800" border="0" cellspacing="0" cellpadding="5" class="cf_table">
<tr>
<th colspan="3" align="left" class="cf_lglabel cf_th">Activity Log</th>
</tr>
<tr>
<td><strong>Action</strong></td>
<td><strong>User</strong></td>
<td><strong>Time</strong></td>
</tr>
<cfif actionlog.recordcount eq 0>
<tr><td colspan="3" align="center" class="cf_red cf_bold">No user actions found</td></tr>
<cfelse>
<cfoutput query="actionlog">
<tr>
<td>#action_done#</td>
<td>#user_name#</td>
<td>#Dateformat(action_time,"dd/mm/yyyy")# #Timeformat(action_time,"h:mm:sstt")#</td>
</tr>
</cfoutput>
</cfif>
</table>