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

Databases and tables

Utility to copy DBFs from one DBC to another DBC by ramani
Posted: 8 Apr 01

*********************************************************
** VFP-6 utilities (see no warranty at bottom)
** Author : Subramanian.G
**          E-mail: ramani_g@yahoo.com
**  
** Used at development time to copy DATABASE files from
** one project to another project
** specify FROM DBC & TO DBC with full path
*********************************************************
** Method to operate...........
** Keep this routine in the project directory as "CopyDbf.prg"
** From the command window issue DO CopyDbf
**
** I had kept the collection of all my utils in a Prcedural file
** and used to call it from that collection.
*********************************************************

** PROCEDURE gs_CopyDBF

DEFINE WINDOW MYWINDOW FROM 5,0 TO 20,80 COLOR SCHEME 5
ACTIVATE WINDOW MYWINDOW

STORE SPACE(40) TO tFromDBC, tToDBC, tDBFname && suitably increase size to your needs

@ 2,5 SAY "Select Source DBC with full path : " Get tFromDBC
@ 4,5 SAY "Select Destination DBC with path : " Get tToDBC
@ 6,5 SAY "Select Source DBF Database name  : " Get tDBFname

READ

IF EMPTY(tFromdbc) .OR. EMPTY(tToDBC) .OR. EMPTY(tDBFname)
    DEACTIVATE WINDOW MYWINDOW
    RETURN
ENDIF
tFromDBC = ALLT(tFromDBC)
tToDBC = ALLT(tToDBC)
tDBFname = ALLT(tDBFname)

CLOSE DATABASES ALL

LOCAL lnObjectId, lnNewId, lnParentId, lcFromDBF, lcToDBF

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

RUN COPY &lcFromDBF &lcToDBF

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

USE (tFromDBC+".DBC") IN 2 ALIAS old
SELECT old
PACK
LOCATE FOR ALLTRIM(UPPER(OBJECTNAME)) == ALLTRIM(UPPER(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

DEACTIVATE WINDOW MYWINDOW

RETURN

** ENDPROC
*********************************************************
** End
*********************************************************
** NO IMPLIED OR EXPLICITY WARRANTY FOR ABOVE.
** USE TO YOUR CONVENIENCE
** DISTRIBUTE WITH THIS NOTE and in complete.
** Any modification, if you feel, is useful for community,
**     please be kind to e-mail me - ramani_g@yahoo.com
*********************************************************

- Ramani
Subramanian.G, FoxAcc Software, (ramani_g@yahoo.com)
********************************************************
Evaluate this to make others know how useful is this



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