I placed the query into an array so that we can dynamically hop around the
record set as needed.  This allows us to loop the each record selectively,
but only once for each display

I am using a multi dimensional array in case you want to use some of the
other file information for display (or your own information). You can switch
it to a single if you are only going to output the file name and speed it up
a tad.

This code places each item in it's own table cell rather than just doing
<br>'s in each column.

Pretty fast processing time . . .  Just copy this into a file and its ready
to run - you'll get it from there  =)

Nate Nielsen
[EMAIL PROTECTED]
[EMAIL PROTECTED]

------------COPY BELOW----------------

<cfdirectory action="LIST" directory="c:\" name="myDir">

<cfscript>
 myFiles = arrayNew(2);
 i = 1;
 numOfColumns = 5;
</cfscript>
<cfloop query="myDir">
 <cfscript>
  myFiles[i][1] = myDir.name;
  myFiles[i][2] = myDir.size;
  myFiles[i][3] = myDir.type;
  i = i + 1;
 </cfscript>
</cfloop>

<table border="1">
<cfloop from="1" to="#val(ceiling(arrayLen(myFiles) / numOfColumns))#"
index="multiplier">
 <tr>
 <cfloop from="1" to="#numOfColumns#" index="i">
  <cfoutput>
   <cfset thisIndex = val((ceiling(arrayLen(myFiles) / numOfColumns)) * (i -
1) + (multiplier))>
   <cfif arrayLen(myFiles) GTE thisIndex>
    <td>#myFiles[thisIndex][1]#</td>
   <cfelse>
    <td>&nbsp;</td>
   </cfif>
  </cfoutput>
 </cfloop>
 </tr>
</cfloop>
</table>
----- Original Message -----
From: "phumes1" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 15, 2002 1:09 PM
Subject: RE: ARGH!!! Can this be done?


>
> It is probably so simple but I just can't get it. Below is my code. How do
> I incorporate the directory structure listing?
>
> <cfparam name="dir" default="d:\">
>
> <cfset RecNo=0>
>
> <cfoutput query="dirlist">
>          <cfset RecNo=RecNo + 1>
>          <cfset Session.stDirFileName[RecNo] = Name>
> </cfoutput>
>
>
> <cfoutput>
> <table border="0" cellpadding="0" cellspacing="0" width="100%"
height="20">
>
> <cfloop index="i" from="1" to=#RecNo#>
>          <cfloop index="LineNo" from=#i# to=#i#>
>                  <cfif Session.stDirFileType[i] eq "File">
>                          <tr height="20">
>                                  <td>#indent#</td>
>                                  <td width="18" height="20"></td>
>                                  <td valign="middle" width="100%"
height="20">
>                                  <!---
>                                  [L:#LineNo#][R:#RecNo#]
>                                  --->
>                                  <!--- Display file names --->
>                                  #Session.stDirFileName[i]#
>                                  </td>
>                          </tr>
>
>                  </cfif>
>          </cfloop>
> </cfloop>
> </table>
>
> </cfoutput>
>
>
>
>
> At 12:44 PM 5/15/2002 -0500, you wrote:
>
> >Darned "off-by-one" conditions!  This is all from me...
> >
> ><cfset TotalSales = #sales.RecordCount#>
> ><cfset NumRows    = TotalSales / 8>      <!--- Want 8 columns --->
> ><cfset IntRows    = int( NumRows + 0.99 )>  <!--- Probably a native that
> >will do this but... --->
> >
> ><table border="1">
> >
> >    <tr><td valign="top">
> >
> >      <cfoutput query="sales">
> >        <cfif NOT ((currentrow-1) MOD IntRows)>
> >          </td><td valign="top">
> >        </cfif>
> >
> >        #ID#. #AuctionType#-#AuctionID#<br>
> >      </cfoutput>
> >
> >   </td></tr>
> >
> ></table>
> >
> >
> >-----Original Message-----
> >From: Eli Sanders [mailto:[EMAIL PROTECTED]]
> >Sent: Wednesday, May 15, 2002 12:16 PM
> >To: [EMAIL PROTECTED]
> >Subject: RE: Can this be done?
> >
> >
> >Yes...! Code below...
> >
> ><CFDIRECTORY DIRECTORY="c:" NAME="myDirectory" >
> ><!--- Output the contents of the CFDIRECTORY as a CFTABLE --->
> ><table>
> ><cfset x = 0>
> ><cfoutput query="mydirectory">
> >         <cfif name neq '. ' or name neq '.. '>
> >         <cfif x eq 0>
> >         <tr>
> >         </cfif>
> >         <cfset x = x + 1>
> >         <td>#Name#</td>
> >         <cfif x eq 3>
> >         </tr>
> >         <cfset x = 0>
> >         </cfif>
> >         </cfif>
> ></cfoutput>
> ></table>
> >
> >-----Original Message-----
> >From: phumes1 [mailto:[EMAIL PROTECTED]]
> >Sent: Wednesday, May 15, 2002 11:57 AM
> >To: [EMAIL PROTECTED]
> >Subject: Re: Can this be done?
> >
> >
> >
> >Hi,
> >
> >This might be a crazy question but here it goes.
> >
> >I'm using <cfdirectory to list files on our server. Some directories can
> >
> >have a 100+ files in them. Presently I'm displaying the list down the
> >left
> >side of my webpage under each other.
> >
> >file1.txt
> >file2.txt
> >file3.txt
> >file4.txt
> >file5.txt
> >etc...
> >
> >I was wondering if there is a way automatically using a table to do the
> >following and if so, how?
> >
> >
> >file1.txt   file5.txt   file9.txt     file13.txt   file17.txt
> >file2.txt   file6.txt   file10.txt   file14.txt   file18.txt
> >file3.txt   file7.txt   file11.txt   file15.txt   file19.txt
> >file4.txt   file8.txt   file12.txt   file16.txt   file20.txt
> >
> >
> >
> >+-----------------------------------------------------------------------
> >------------+
> >
> >Philip Humeniuk
> >[EMAIL PROTECTED]
> >[EMAIL PROTECTED]
> >+-----------------------------------------------------------------------
> >-------------+
> >
> >
> >
> >------------------------------------------------------------------------
> >-
> >This email server is running an evaluation copy of the MailShield anti-
> >spam software. Please contact your email administrator if you have any
> >questions about this message. MailShield product info:
> >www.mailshield.com
> >
> >-----------------------------------------------
> >To post, send email to [EMAIL PROTECTED]
> >To subscribe / unsubscribe: http://www.dfwcfug.org
> >
> >-------------------------------------------------------------------------
> >This email server is running an evaluation copy of the MailShield anti-
> >spam software. Please contact your email administrator if you have any
> >questions about this message. MailShield product info: www.mailshield.com
> >
> >-----------------------------------------------
> >To post, send email to [EMAIL PROTECTED]
> >To subscribe / unsubscribe: http://www.dfwcfug.org
> >
> >-------------------------------------------------------------------------
> >This email server is running an evaluation copy of the MailShield anti-
> >spam software. Please contact your email administrator if you have any
> >questions about this message. MailShield product info: www.mailshield.com
> >
> >-----------------------------------------------
> >To post, send email to [EMAIL PROTECTED]
> >To subscribe / unsubscribe: http://www.dfwcfug.org
> >
> >-------------------------------------------------------------------------
> >This email server is running an evaluation copy of the MailShield anti-
> >spam software. Please contact your email administrator if you have any
> >questions about this message. MailShield product info: www.mailshield.com
> >
> >-----------------------------------------------
> >To post, send email to [EMAIL PROTECTED]
> >To subscribe / unsubscribe: http://www.dfwcfug.org
>
>
>
+---------------------------------------------------------------------------
--------+
>
> Philip Humeniuk
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
+---------------------------------------------------------------------------
---------+
>
>
>
> -------------------------------------------------------------------------
> This email server is running an evaluation copy of the MailShield anti-
> spam software. Please contact your email administrator if you have any
> questions about this message. MailShield product info: www.mailshield.com
>
> -----------------------------------------------
> To post, send email to [EMAIL PROTECTED]
> To subscribe / unsubscribe: http://www.dfwcfug.org


-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to