>Rich
>
>You code is good and appends from tables of the old folder
>to all tables of the new folder
>
>However I notice that if there is a table present only in the old
>folder that is not present in the new folder it will try to append
>
>How can I skip the code from processing tables that only exist
>on the old folder ?
>
>
>
>lcAppendIntoPath = ADDBS(myIntoPath)
>lcAppendFromPath = ADDBS(myFromPath)
>lnNumTables = ADIR(aTables,lcAppendFromPath+"*.dbf")
>SELECT 0
>FOR I = 1 TO lnNumTables
> TRY
> USE (lcAppendIntoPath+aTables[i,1] EXCLUSIVE
> ZAP
> APPEND FROM (lcAppendFromPath+aTables[I,1])
> CATCH
> =MESSAGEBOX("Cannot open "+lcAppendIntoPath+aTables[I,1])
> ENDTRY
>ENDFOR
>USE
You will have (have had?) similar problems if a file exists in the new folder but not the old one.
In my mind, it doesn't matter which directory develops the list of files. You can process all the files in either folder. What you need is some mechanism to make sure each file exists in both folders.
One way is to develop two arrays (via ADIR()) and make sure the files exist in both. I believe that's the way you first started. Another is to get an array of files for one directory and use FILE() to see if it exists in the other. From the number of posts about FILE() not working correctly, I don't think that's a good idea.
In a post on another thread Naomi suggested using TRY/CATCH in a similar situation and I adapted that to your situation. I think it is the simplest way of doing it. Simply generate a list of files from
either folder. Then you
TRY to USE the file from the new folder and APPEND the records from the old folder. If one of the files doesn't exist you will
CATCH the resulting error, deal with it, and continue processing the rest of the files.
My code informed you of the problem by presenting a MESSAGEBOX(). If you don't need to know about the missing files, simply remove the MESSAGEBOX() line. If you want to know but don't want to react to the messagebox, print them to the screen via
? "Cannot open "+lcAppendIntoPath+aTables[I,1]
or some such. You can get as complicated as you want with the CATCH - even to the extent of saving a list of unprocessed files and sending them via an email.
Hope this helped............Rich