Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Day
Message
From
17/03/2004 09:58:00
 
 
To
17/03/2004 07:21:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00878450
Message ID:
00887054
Views:
11
A simple example:
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
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform