>Hi Nadya,
>
>I ran out of time and did not test REPLACE ALL vs. SCAN ... ENDSCAN. I never got REPLACE ALL to work in a repetitive fashion such as
>
>REPLACE ALL thisfield WITH X
>REPLACE ALL thatfield WITH X
>and so on ...
>
>I was told by someone that speed-wise they would be about the same, but I don't know if that is true. I am curious too.
>
Unless there's some hidden optimization going on in VFP's interpreter, that'd be hard to do - two statements means two separate passes at least through data in memory, even if the REPLACEs were fully optimizable. Try generating a huge garbage table by:
CREATE TABLE Gbg (cFld1 C(10), cFld2 C(10))
FOR i = 1 TO 2000000
INSERT INTO GBG VALUES (SYS(2015), SYS(2015))
ENDFOR
Exit from VFP to flush all buffers, and reboot between runs to make sure that cache is excluded as an issue for initial start points. Run:
tStart = DATETIME()
REPLACE ALL cFld1 WITH SYS(2015), cFld2 WITH SYS(2015)
? DATETIME() - tStart
vs
tStart = DATETIME()
REPLACE ALL cFld1 WITH SYS(2015)
REPLACE ALL cFld2 WITH SYS(2015)
? DATETIME() - tStart