INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Usefull Functions & Procedures

DBF of Volumes/Directory/Files by dgrewe
Posted: 5 Mar 07

*/*********************************************************
*# Directory to DataBaseFile
*/Program   : Function Dir2Dbf
*/System    : Fox Library
*/Purpose   : Places All Default Directory Files into a database called FILES.DBF
*/          : Places All Directories off the default directory in a database called DIRECTRY.DBF
*/          : Places All Computers Drives (Hard, Logical and Network) in a database called DRIVES.DBF
*/Syntax    : Integer = dir2dbf(Files, Directorys, Drives, Local, TestMode)
*/Returns   : Integer - The number of files in the directory
*/Parameter : File - Logical - Create FILES.DBF
*/          : Dire - Logical - Create DIRECTRY.DBF
*/          : Driv - Logical - Create DRIVES.DBF
*/            : Loca - Location to place Files
*/            : Test - Logical - Run in Debug mode
*/Defaults  : Local = "C:\temp\"
*/            : All other Parameters Not Passed Are Set to False
*/Requires  : Nothing
*/Changes   : the contents of Files.dbf, Directry.dbf and Drives.dbf
*/Calls     : Nothing
*/Version   : 1.0
*/Dated     : 10 July 1989
*/Written By: David W. Grewe
*/**********************************************************
*& Utility - Program
*/**********************************************************
*/ Record Of Change
*/
*/**********************************************************
PARAMETERS plFile, plDire, plDriv, pcLocal, plTest
*
* Check Parameters passed to function
*
IF plTest
    SET STEP ON
ENDIF
IF EMPTY(pcLocal) OR PARAMETERS() < 4
    pcLocal = "C:\Temp\"
ENDIF
*
* Set Local Memvars
*
LOCAL lcDefaultDir,lnDir2Dbf,lnSelect,lcOnError
lcDefaultDir = ""
lnDir2Dbf = 0
lnSelect = SELECT(0)
lcOnError=ON("ERROR")
DIMENSION laFiles(1,5)
*
* Create the directory to place the files in
*
IF !DIRECTORY(pcLocal)
    lcDefaultDir = SYS(5) + SYS(2003)
    ON ERROR *
    MKDIR &pcLocal
    ON ERROR &lcOnError
ENDIF
*
* Create Table of File is Directory
*
IF  plFile = .t.
    =deltables("FILES")
    lnDir2Dbf = adir(laFiles , "*.*")
    =ASORT(laFiles,1)
    SELECT  0
    CREATE TABLE (pcLocal+"FILESDBF.DBF") (NAME c(50), SIZE n(10,0), DATE d, TIME c(8), ATTRIB c(4), DIRECTORY c(50))
    APPEND FROM ARRAY laFiles
    SORT TO (pcLocal+"FILES.DBF") ON NAME FOR FILESDBF.SIZE > 1
    USE  IN  FILESDBF
    DELETE  FILE(pcLocal+"FILESDBF.DBF")
ENDIF
*
* Create Table of Directories
*
IF  plDire = .t.
    =deltables("DIRECTORY")
    SELECT  0
    CREATE TABLE (pcLocal+"FILESDBF.DBF") (NAME c(50), SIZE n(10,0), DATE d, TIME c(8), ATTRIB c(4), DIRECTORY c(50))
    lnDir2Dbf= ADIR(laFiles , "*" , "D")
    =ASORT(laFiles,1)
    APPEND FROM array laFiles
    DELETE ALL FOR SIZE > 1
    DELETE ALL FOR NAME = "."
    SET DELETED ON
    SORT TO (pcLocal+"DIRECTRY.DBF") ON NAME FOR NOT DELETED()
    USE (pcLocal+"DIRECTRY.DBF")
    lnDir2Dbf= reccount()
    USE
    DELETE FILE(pcLocal+"FILESDBF.DBF")
ENDIF
*
* Create table of Drive letters
*
IF  plDriv = .t.
     DelTables("DRIVES")
    SELECT  0
    CREATE TABLE (pcLocal+"DRIVES.DBF") (LETTER c(1), LABEL c(15))
    FOR I = 65 TO 90
        lnType = DRIVETYPE(CHR(i)+":")
        IF  lnType<>1
            =ADIR(laFiles , chr(i)+":" , "DV")
            APPEND BLANK
            replace LETTER WITH CHR(i)
            replace LABEL  WITH laFiles(1)
        ENDIF
    ENDFOR
    lnDir2Dbf= RECCOUNT()
    USE IN DRIVES
ENDIF
*
* Clean up
*
SELECT (lnSelect)
RELEASE  laFiles
RELEASE lnSelect,lcDefaultDir
RELEASE plFile, plDire, plDriv, pcLocal, plTest
RETURN  lnDir2Dbf
*
*
*
PROCEDURE DELTABLES
LPARAMETERS pcTable
IF  USED(pcTable)
    SELECT (pcTable)
    USE IN (pcTable)
ENDIF
DELETE FILE (pcLocal + pcTable+".DBF")
IF  USED("FILESDBF")
    SELECT FILESDBF
    USE IN FILESDBF
ENDIF
DELETE FILE(pcLocal +"FILESDBF.DBF")
RETURN



Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close