Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DIR command output??
Message
De
11/08/2011 09:38:56
 
 
À
11/08/2011 09:13:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01520669
Message ID:
01520675
Vues:
86
>Is there any way to make the output from the DIR command show more information about the files in the current directory? I would expect to see output much like the old DOS command where it shows columns of information that include the filename, date, and file size in a vertical flowing format.
>
>It seems that the DIR command in FoxPro is designed to work with DBF files be default, and it does show more info about those files.
>
>However, if you use Dir *.*, then what FoxPro spits out is some dorky sideways list of just file names, without the date and filesize. It's just really hard to read. What were they thinking?
>
>
>Has anyone developed a better DIR command for VFP????

In my library I have this old DIRBRIW,PRG which you easily can modify
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
I also have this program to create a cursor of a directory
Lparameters pcSkeleton, pcCursorname, plMoreinfo
Local lcFilename, llNeste, lcPath, lnLen
If Pcount()<1 Or Vartype(pcSkeleton)#'C' Or (Pcount()>1 And Vartype(pcCursorname)#'C')
   Return -1
Else    
   If Pcount()=1
      pcCursorname='curDumyDir'
   Endif 
   llNeste=.F.
   Create Cursor (pcCursorname) (filnavn c(1))
   Do While .t.
      If llNeste
         lcFilename=Sys(2000,pcSkeleton,1)
      Else 
         lcFilename=Sys(2000,pcSkeleton)
      Endif 
      If Len(lcFilename)>len(filnavn)
         lnLen=Len(lcFilename)
         Alter Table (pcCursorname) alter Column filnavn c(lnLen)
      Endif 
      If !Empty(lcFilename)
         Insert Into (pcCursorname) (filnavn) Values (Juststem(lcFilename))
      Else 
         Exit 
      Endif 
      llNeste=.T.
   Enddo 
Endif    
If Reccount()>0 And plMoreinfo
   Alter Table (pcCursorname) Add column dato d
   Alter Table (pcCursorname) Add column fsize i
   Alter Table (pcCursorname) Add column fulltnavn c(lnLen)
   Scan
      Adir(aDummy,(Addbs(justpath(pcSkeleton)) + Trim(filnavn) + '.' + Justext(pcSkeleton)))
      replace dato With aDummy(3), fsize With aDummy(2), fulltnavn With aDummy(1)
   Endscan 
Endif 
Return Reccount()
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform