> I have developed an application which uses over 17 tables from another application.
>
> I want to make a copy of each table with a new name in a folder and open each one.
>
> At present I am using the following code each time
>
> eg for TEMP_C
>
>
>
> SELECT TEMP_C
>
> myorigfilename ="TEMP_C"+'.dbf'
>
> mycopyfilename = "TEMP_CC"+'.dbf'
>
> CopyFile (myorigfilename , mycopyfilename, 0)
>
> myorigfilename ="TEMP_C"+'.fpt'
>
> mycopyfilename = "TEMP_CC"+'.fpt'
>
> CopyFile (myorigfilename , mycopyfilename, 0)
>
> *!* COPY to TEMP_CC - replaced by API call
>
> USE
>
> IF !used('TEMP_CC')
> USE TEMP_CC in 0
> ENDIF
>
>
>
> Can a clever more experienced coder than me put all this in a FOR NEXT form that I can use instead?
>
> I will manually create an array of the old TEMP filenames and corresponding new TEMP filenames as they will never change.
>
> I already have many prgs using the new filenames.
>
> I am doing this so that the tables form the original application are not changed by my app.
>
> Many thanks
>
> -Bryan
Hi Bryan,
I'm not sure how this helps you...But you could have a try...Thanks!
[Edited]
Local lnOrigDBFCount,lnOrigFPTCount,lnOrigCDXCount
Local myorigfilename,mycopyfilename
Local lcOriginalPath,lcCopyPath
Local lnNewDBFCount,lnNewFPTCount,lnNewCDXCount
Declare Integer CopyFile In kernel32;
STRING lpExistingFileName,;
STRING lpNewFileName,;
INTEGER bFailIfExists
lcoldPath = Set("Default")
Set Default To "C:\temp1\" &&Suppose \temp1 have .dbf, .fpt & .cdx files
lnOrigDBFCount = Adir(arOrigDBF,"*.DBF")
lnOrigFPTCount = Adir(arOrigFPT,"*.FPT")
lnOrigCDXCount = Adir(arOrigCDX,"*.CDX")
*Copy FPT Files to Target folder
If lnOrigFPTCount > 0
For ix=1 To lnOrigFPTCount
myorigfilename = arOrigFPT(ix,1)
mycopyfilename = "Cc_"+myorigfilename
CopyFile (myorigfilename , mycopyfilename, 0)
Next
Endif
*Copy CDX Files to Target folder
If lnOrigCDXCount > 0
For ix=1 To lnOrigCDXCount
myorigfilename = arOrigCDX(ix,1)
mycopyfilename = "Cc_"+myorigfilename
CopyFile (myorigfilename , mycopyfilename, 0)
Next
Endif
&& Finally copy the DBF Files to Target folder to enusre all
&& depended files copied already!
If lnOrigDBFCount > 0
For ix=1 To lnOrigDBFCount
myorigfilename = arOrigDBF(ix,1)
mycopyfilename = "Cc_"+myorigfilename
CopyFile (myorigfilename , mycopyfilename, 0)
If !Used(mycopyfilename)
Use &mycopyfilename In 0 && Originals files are not used at all!
&&Do the process here...
Wait Window 'Table Opened: '+ mycopyfilename Nowait Noclear
Use In Juststem(mycopyfilename) &&Close if not need any more
Endif
Next
Endif
Wait Clear
Erase cc_*.*
Set Default To &lcoldpath
Regards,
Jyothish