I'd like to second BobW in NOT using DCOUNT in a FOR line.  Certainly
when the count is small the overhead is also small, but how many times
are we DCOUNTing with certainty that we know the count is less than a
particular threshold?  Whether the count is zero or higher, I believe
it's always better to assign the count to a variable and then loop to
the variable; then there's no chance for surprises when the program
does encounter an unexpectedly big list.

Furthermore, at the risk of offending delicate sensibilities, I take
this a step farther and recommend specific variable names for FOR
statements.  If the list is in a variable called INVOICES, the loop
would be:

INVOICES.CNT = DCOUNT(INVOICES,@VM)
FOR INVOICES.LOOP = 1 TO INVOICES.CNT
..
NEXT INVOICES.LOOP

(That is, loop variables always end in .LOOP, loop max counts always
end in .CNT, and the prefix is the original variable name.  It has
been my experience that tying the loop max and loop counter to the
original variable name (by convention) improves the clarity and
purpose of the loop.  Your individual results may vary.)

This is assuming, of course, that the FOR/NEXT loop is the proper
construct for the particular task at hand.  If the list is anticipated
to be large or there are other extenuating circumstances due to the
format of the data being looped through, FOR/NEXT may not be the best
choice.

-K
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to