Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 To: bryan wetton
  Where is bryan wetton?
 Morphett Vale
 Australia
 bryan wetton
 Tags
Subject: RE: Confusion with parameters and OPEN
Thread ID: 209211 Message ID: 209270 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Friday, December 26, 2008 1:49:04 PM         
   


Bryan

This routine copies all the DBF files in the directory specified by the filename passed in to the specified Destination Directory (there is a default in there if no directory is passed):

DO CopyFiles WITH 'comlist.dbf', 'X:\LocCopies'


Save this and run it
********************************************************************
*** Name.....: COPYFILES.PRG
*** Author...: Andy Kramek & Marcia Akins
*** Date.....: 12/26/2008
*** Notice...: Copyright (c) 2008 Tightline Computers, Inc
*** Compiler.: Visual FoxPro 09.00.0000.3504 for Windows 
*** Function.: Copies all DBF from one location
*** Returns..: Default
********************************************************************
LPARAMETERS tcFileName, tcDestDir
LOCAL lcOldDir, lcDestPath, lcSceFile, lcScePath, loErr, lnFiles, lnCnt, lcCurSce, lcDestFile

TRY
  *** Save current directory
  lcOldDir = FULLPATH( CURDIR())

  *** Set the destination path (default if not passed)
  lcDestPath = IIF( VARTYPE( tcDestDir ) <> "C" OR EMPTY( tcDestDir ), 'E:\Temp', tcDestDir )
  
  *** These define the source file
  IF FILE( tcFileName )
    lcSceFile = FULLPATH( LOCFILE( tcFileName, 'dbf' ))
  ELSE
    ERROR 'Source File Not found'
  ENDIF 

  *** Get the file path and alias name from the file name
  lcScePath = JUSTPATH( lcSceFile ) 
  lcSceAlias = JUSTSTEM( lcSceFile )

  *** And change to the directory
  SET DEFAULT TO ( lcScePath )

  *** Now get all the files into an array
  lnFiles = ADIR( laFiles, '*.dbf' )
  
  FOR lnCnt = 1 to lnFiles
    *** Get the file name 
    lcCurSce = laFiles[ lnCnt, 1]
    IF LEFT( lcCurSce, 1) = "."
      *** Ignore directories
      LOOP
    ENDIF
    WAIT WINDOW "Copying Table: " + lcCurSce NOWAIT

    *** Open the file for copy
    USE (lcCurSce) SHARED NOUPDATE
 
    *** Set the destination name
    lcDestFile = ALIAS() + "_cc"
 
    *** Copy to rermote destination 
    COPY TO ( ADDBS( lcDestPath ) + FORCEEXT( lcDestFile, 'dbf') ) PRODUCTION
  NEXT    
  *** Tidy up
  CLOSE TABLES ALL
      
CATCH TO loErr
  MESSAGEBOX( loErr.Message + CHR(13) + CHR(10) + loErr.LineContents, 16, 'File Copy Error' )

FINALLY
  *** Restore Working Directory
  SET DEFAULT TO (lcOldDir)

ENDTRY

Regards
Andy Kramek
Microsoft MVP (Visual FoxPro)
Tightline Computers Inc, Akron Ohio, USA

ENTIRE THREAD

Confusion with parameters and OPEN Posted by bryan wetton @ 12/26/2008 12:38:45 AM
RE: Confusion with parameters and OPEN Posted by Andy Kramek @ 12/26/2008 2:25:11 AM
RE: Confusion with parameters and OPEN Posted by bryan wetton @ 12/26/2008 2:37:04 AM
RE: Confusion with parameters and OPEN Posted by Andy Kramek @ 12/26/2008 1:49:04 PM
RE: Confusion with parameters and OPEN Posted by bryan wetton @ 12/27/2008 2:32:06 AM
RE: Confusion with parameters and OPEN Posted by Andy Kramek @ 12/27/2008 4:05:04 AM
RE: Confusion with parameters and OPEN Posted by bryan wetton @ 12/27/2008 5:07:54 AM
RE: Confusion with parameters and OPEN Posted by Andy Kramek @ 12/27/2008 7:06:59 PM
RE: Confusion with parameters and OPEN Posted by bryan wetton @ 12/27/2008 11:04:24 PM