> Thanks for the code Brad.
>
> I have needed to alter it somewhat as it wasn't quite what I needed.
>
> The required tables are in the 'master' app's project folder in My Documents
>
> I have the table listing the required tables in my app's program folder.
>
> I use a temp folder such as C:\Documents and Settings\bryan\Application Data\tagwiz\
>
> I have a third column for the required new name - the second column has another reference
>
> so I need the copied files in that temp folder - but I am not getting a copy of the table in the temp folder. I have tried two methods.
>
> Here is my code
>
>
>
> Set Default To (mysystempath) && my app program folder
>
> Select * From TMGTables Into Array laTableInfo
> *
> * laTableInfo[] is a 3-dimensional array
> * that contains the Original Table Name and the Name of the Copy...
> *
> * So, for example...
> * laTableInfo[1,1]="TEMP_C"
> * laTableInfo[1,3]="TEMP_CC"
>
> For xx=1 To Alen(laTableInfo,1)
> For lnExt=1 To 3
> lcExt=Icase(lnExt=1,".DBF",lnExt=2,".FPT",".CDX")
> If File(Alltrim(laTableInfo[xx,1])+lcExt)
> lcOldfilename = Alltrim(laTableInfo[xx,1])+lcExt
> lcNewfilename = (mydatapath)+Alltrim(laTableInfo[xx,3])+lcExt
> logging(lcOldfilename)
> logging(lcNewfilename)
> && first alternative method
> COPY FILE(lcOldfilename )TO (lcNewfilename)
> && original method
> CopyFile(lcOldfilename,lcNewfilename,0)
> Endif
> Endfor
> Set Default To (mydatapath)
>
> * open dbf
>
> If Not Used(lcNewfilename )
> Use (lcNewfilename) In 0
> Endif
> Set Default To (mysystempath)
>
> Endfor
>
> Do openings - to test for open tables at a point in the code - writes to log
>
>
>
>
> The output to the log file is
>
> 5:39:01 PM sample_$.DBF
> 5:39:02 PM C:\Documents and Settings\bryan\Application Data\tagwiz\temp_LL.DBF
>
> all the way to
>
> 5:56:19 PM sample_t.CDX
> 5:56:19 PM C:\Documents and Settings\bryan\Application Data\tagwiz\temp_TT.CDX
> 5:56:19 PM File Open in Area 1 is TAGS 84
> 5:56:19 PM File Open in Area 3 is MYPATHS 1
> 5:56:19 PM File Open in Area 4 is TMGTABLES 16 - list of tables to be copied
>
> times are for different runs.
>
> Hoping you can see where I am in error...
>
> Merry Christmas.
>
>
> -Bryan
In looking at the output of your log file, I would guess that the file IS being COPIED okay. But the copied file is not being opened. I think that's because of your test with the USED() function.
The USED() function takes as an argument an ALIAS name, and NOT a FILE name.
Try changing the USED line so that it says:
IF USED(JUSTSTEM(lcNewFilename))
--Brad