I like Jamie's method and think it's probably the best, but I thought I'd just throw another idea into the mix. I wrote a couple of (untested) UDF's that will recursively look for the previous/next file until it finds it. The "safetyCounter" is there to avoid an endless loop, so you can adjust the number as you see fit. Just a thought. -Brad <cfscript> function getPreviousFile(fileDir,fileID) { var newID = fileID - 1; var filePath = fileDir & '\' & newID & '.cfm'); var safetyCounter = 1; if (arrayLen(arguments GTE 3)) { safetyCounter = arguments[3] + 1; if (safetyCounter GTE 20) { return ""; } if (fileExists(filePath)) { return newID; } else { return getPreviousFile(fileDir, newID, safetyCounter); } } function getNextFile(fileDir,fileID) { var newID = fileID + 1; var filePath = fileDir & '\' & newID & '.cfm'); var safetyCounter = 1; if (arrayLen(arguments GTE 3)) { safetyCounter = arguments[3] + 1; if (safetyCounter GTE 20) { return ""; } if (fileExists(filePath)) { return newID; } else { return getNextFile(fileDir, newID, safetyCounter); } } </cfscript> -----Original Message----- From: Paul Giesenhagen [mailto:[EMAIL PROTECTED] Sent: Monday, September 22, 2003 4:02 PM To: CF-Talk Subject: Previous/Next with Files I have a directory that can have a small amount or possibly a large amount of files (3,000) files. Here would be an excerpt of the directory: 10330.cfm 10331.cfm 10336.cfm 10440.cfm 10441.cfm 10442.cfm 10445.cfm etc.. If someone is looking at 10440.cfm, I would like to have two links a link to 10336.cfm (previous) and a link to 10441.cfm (next). I could do a CFdirectory and populate a list with all the file names and then look to the before and after the selected file for the next/previous, but that seems alittle intensive. Does anyone have any suggestions on the most efficient way to get next/previous files? Any help would be appreciated! Paul Giesenhagen QuillDesign ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to