How to display a list of files in a grid


I received a question from a customer:


 


I am trying to find a way to display a grid of files (specifically DBF files) and show them in the order they were created with the dates and file sizes. 


 


I just took the sample code from Add a slider control to your TreeMap to vary how much detail is shown and cut/paste and the result is below.


It uses the  AllowCellSelection property which allows the grid to mimic a listbox.


 


 


 


CLEAR ALL


CLEAR


PUBLIC oForm


oForm=CREATEOBJECT(“MyForm”,ADDBS(GETDIR(“c:\program files”)),“*.exe”,.f.)


 


DEFINE CLASS MyForm as Form


          AllowOutput=.f.                 && so ‘?’ output goes to screen


          Width=_screen.Width


          Height=_screen.Height-50


          Width=1024


          Height=798


          PROCEDURE init(cPath as String, cMask as string, fSubDir as Boolean)


                   SET EXCLUSIVE OFF


                   SET SAFETY OFF


                   SET TALK off


                   SET EXACT OFF


                   CREATE table Files (path c(240),fname c(240),fsize n(10,0),timestamp t)


                   this.DoDir(cPath,cMask)


                   INDEX on timestamp DESCENDING TAG t   && choose your desired order


*                  INDEX on fsize DESCENDING TAG fsize


                  


                   this.AddObject(“gr”,“grid”)


                   this.gr.AllowCellSelection=.f.


                   this.gr.Visible=1


                   this.gr.Height=thisform.Height


                   this.gr.Width = thisform.Width


                   this.gr.Autofit


                   this.gr.Column3.InputMask=“999,999,999”


                   this.Show


          PROCEDURE DoDir(cPath as String, cMask as String)


                   LOCAL n,i,aa[1]


                   n=ADIR(aa,cPath+cMask,“”,1)


                   FOR i = 1 TO n


                             INSERT INTO files (Path,fname,fsize,timestamp) VALUES ;


                                      (cPath, aa[i,1], aa[i,2],CTOT(DTOC(aa[i,3])+aa[i,4]))


                   ENDFOR


                   n=ADIR(aa,cPath+“*.*”,“HD”,1)     && now without the mask, search for directories


                   FOR i = 1 TO n


                             IF “D”$aa[i,5] && if it’s a dir


                                      IF aa[i,1] != ‘.’


                                                this.DoDir(cPath+aa[i,1]+“\”,cMask)         && recur


                                      ENDIF


                             ENDIF


                   ENDFOR


ENDDEFINE


 

Comments (6)

  1. Calvin_Hsia says:

    The timestamp code is slightly wrong: need to add a space between the date and time before calling DTOC():

    aa[i,3])+" "+aa[i,4]

  2. Smith says:

    Hey, I have some links here,thanks.

  3. garry-yw says:

    <a href= http://ikdoeei.angelfire.com >cowpiebunkhouse</a> <a href= http://kosaaea.angelfire.com >beverly kirk and wjla</a> <a href= http://lowiozi.angelfire.com >aaa and radio and format</a> <a href= http://eheqibs.angelfire.com >waterford logo year started</a> <a href= http://nwcijgg.angelfire.com >i fi had a dream tonight id dream that id be with you lyrics</a>

  4. jyner_jo says:

    <a href= http://index1.frigats.ru >������ ����� ���������</a> <a href= http://index2.frigats.ru >������� mp3 ���������</a> <a href= http://index3.frigats.ru >����� ���� �� ��������</a> <a href= http://index4.frigats.ru >����� �������� ��� ������</a> <a href= http://index5.frigats.ru >������� �������� ����� ����</a>

Skip to main content