LOCAL ddir ddir = "\myprogram\data\" && set to path to data files *--Get a list of all tables the system has now =ADIR(afiles,ddir+'*.dbf') LOCAL lndel, lcshort, lcalias, lnpos, lcfile *--Remove deleted records from all files in the afiles array FOR i = 1 TO ALEN(afiles,1) lndel=0 lcfile=ddir+ALLTRIM(afiles(i,1)) lnpos=(RAT("\",afiles(i,1))+1) && one position to the right of IF lnpos>0 lcshort = UPPER(SUBSTR(afiles(i,1),lnpos)) lcalias=UPPER(LEFT(lcshort,RAT(".",lcshort)-1)) ELSE lcshort=UPPER(afiles(i,1)) lcalias=UPPER(LEFT(lcshort,RAT(".",lcshort)-1)) ENDIF IF !FILE(lcfile) *--Messagebox if user is present otherwise store *--all errors to a logfile and create a means *--of notifying admin that errors ocurred during *--the delete/pack process =MESSAGEBOX('Could not locate '+lcfile,0,'ERROR') LOOP ENDIF SELE 0 *Open the table exclusive IF !USEFILE(lcshort,ddir,"",lcalias,'EXCLU') *--Messagebox if user is present otherwise store *--errors to a logfile and create a means *--of notifying admin that errors ocurred during *--the delete/pack process =MESSAGEBOX('Could not open '+lcfile,0,'ERROR') LOOP ENDIF SELECT (lcalias) *--Add your deleted conditional loop here if necessary *--Example SCAN...ENDSCAN, FOR...ENDFOR, DELETE FOR etc *--to delete the records you need to based on your criteria lndel=0 COUNT FOR DELETED() TO lndel IF TYPE('lndel')="N" .AND. lndel>0 WAIT WINDOW "Purging "+lcfile+"..." NOWAIT PACK ENDIF USE IN (lcalias) ENDFOR RETURN