>Hi George,
>
>>>From Steve Black's "Text" session at DevConnections, John's would be more efficient. Some VFP optimization on StrVar = StrVar + ...
>>
>>Bill,
>>
>>I'm not so sure about that. See below
clear
cfoo = 'ABCDEF'
lnstart = SECONDS()
FOR lnj = 1 TO 10000
lcresult = ""
FOR lni = 1 TO 6
lcresult = SUBSTR(lcfoo, lni, 1) + lcresult
NEXT
NEXT
lnstop = SECONDS()
? lnstop - lnstart
lnstart = SECONDS()
FOR lnj = 10000 TO 1 STEP -1
lcresult = ""
FOR lni = 6 TO 1 STEP -1
lcresult = lcresult + SUBSTR(lcfoo, lni, 1)
NEXT
NEXT
lnstop = SECONDS()
? lnstop - lnstart
>Your examples don't include the case that John had and I referenced. i.e.
>lcresult = lcresult + SUBSTR(lcfoo, lni, 1)
>
>Or am I blind? < G >
You're right I didn't include the second case. Originally, I thought, DOH! However, running the test again (corrected above), the first case was about 8% faster in each of 10 consecutive tests. It may be the iterations, but I'm unconvinvced. My tests of the iterations (10,000,000) were inconclusive that it has to be the iterations structures causing the difference.
George
Ubi caritas et amor, deus ibi est