in VFP's Help We can find :
"If you use the LOCATE command without the FOR expression, Visual FoxPro
positions the record pointer at the first logical record. This is faster
than using GO TOP when a filter is in use or when DELETED is ON."For my curiosity, I wanted to know how much faster LOCATE is, but I got the opposite !
Is the information provided by MS wrong , or did I make the test incorectly ???
TEST 1
SET DELETED ON
SET ORDER TO 1
USING LOCATE : 42.76 SECONDS
USING GOTOP : 22.51 SECONDS
TEST 2
SET DELETED ON
SET ORDER TO
USING LOCATE : 30.03 SECONDS
USING GOTOP : 7.89 SECONDS
TEST 3
SET DELETED OFF
SET ORDER TO 1
USING LOCATE : 26.15 SECONDS
USING GOTOP : 22.53 SECONDS
TEST 4
SET DELETED OFF
SET ORDER TO
USING LOCATE : 13.48 SECONDS
USING GOTOP : 7.82 SECONDS
The code I run is :
CLOSE ALL
CLEAR ALL
CLEAR EVENTS
SET DELETED OFF
USE myTable
SET ORDER TO 1
nSecs = SECONDS()
FOR n = 1 TO 10000000
GO BOTTOM
GO TOP
NEXT
MESSAGEBOX(TRANSFORM(SECONDS() - nSecs ) + " Seconds")
I just alternate SET DELETED and SET ORDER.
Regards
Cesar