Click here to save this page

** Utility to copy DBFs from one DBC to another DBC



** Utility to copy DBFs from one DBC to another DBC
**********************************************************
** Author      : Ramani (Subramanian.G)
**               FoxAcc Software / Winners Software
** Type        : Freeware with reservation to Copyrights
** Warranty    : Nothing implied or explicit
**********************************************************
** Used at development time to copy DATABASE files
** from one project to another project
*********************************************************
** Method to operate...........
** Keep this routine in the project directory as "CopyDbf.prg"
** From the command window issue DO CopyDbf
*********************************************************
** PROCEDURE CopyDBF

tFromDBC = GETFILE("DBC","Source DBC")
tDBFname = GETFILE("DBF","Source Table")
tToDBC = GETFILE("DBC","Destination DBC")
IF EMPTY(tFromdbc) .OR. EMPTY(tToDBC) .OR. EMPTY(tDBFname)
	RETURN
ENDIF

CLOSE DATABASES ALL

LOCAL lnObjectId, lnNewId, lnParentId, lcFromDBF, lcToDBF

lcFromDBF = JUSTPATH(tFromDBC)+"\"+JUSTSTEM(tDBFname)+".*"
lcToDBF = JUSTPATH(tToDBC)+"\"+JUSTSTEM(tDBFname)+".*"

RUN COPY &lcFromDBF &lcToDBF

USE (tToDBC) IN 1 ALIAS new
SELECT new
PACK
GO BOTTOM
lnNewId = RECCOUNT()+1
lnParentId = lnNewId

USE (tFromDBC) IN 2 ALIAS old
SELECT old
PACK
LOCATE FOR ALLTRIM(UPPER(OBJECTNAME)) == ALLTRIM(UPPER(JUSTSTEM(tDBFNAME)))
lnObjectId = ObjectId
SCATTER MEMVAR MEMO
m.ObjectId = lnNewId
SELECT new
APPEND BLANK
GATHER MEMVAR MEMO

SELECT old
SCAN FOR ParentId = lnObjectId
	SCATTER MEMVAR MEMO
	lnNewId = lnNewId+1
	m.ObjectId = lnNewId
	m.ParentId = lnParentId

	SELECT new
	APPEND BLANK
	GATHER MEMVAR MEMO
	SELECT old
ENDSCAN
CLOSE DATABASES ALL
ENDPROC
**********************************************************
** End
**********************************************************

Home       Feedback       DataBase       VisualFoxProFAQ