>SCAN always reselects the right work area (the one the loop started in) when it reaches ENDSCAN, so you don't need to reselect even if you've changed work areas inside the loop. We know a lot of people who do so anyway. There doesn't appear to be a performance penalty for this, so if you're the belt-and-suspenders type, go right ahead.
>
Did a little testing, and the perfomance difference is there: (test table has 220000 records)
lnSeconds = SECONDS()
SELE Table1
SCAN
SELECT Table2
SELECT Table1
ENDSCAN
?SECONDS() - lnSeconds
Average over 10 runs: 5.820 seconds
<PRE>
lnSeconds = SECONDS()
SELE Table1
SCAN
SELECT Table2
ENDSCAN
?SECONDS() - lnSeconds
Average over 10 runs: 5.640 seconds
You're right, the difference is nearly negligible, but it's there.
I guess it boils down to a coding preference, but I subscribe to Steve McConnell's theory:
Your program is complete when it does what is needed, and you can't take out any more code without breaking it.
Erik Moore
Clientelligence