Quote:
Wow. If this C code, then you could always do this with a macro and avoid the loop.
Not quite, since I simplified for the sake of being able to post here and have it be readable. The loop is completely unecessary, as all he's doing is going right down the list- you just have to move the common code at the bottom into a method that you call after building each report. The reason a macro wouldn't work is that for each place I have "BuildReportX" there are about 100 lines of code that actually build the report (You know, build a query in line so it's open for SQL injection attack, execute the query, format the results). It is very difficult to read since there are actually 4 of these loops in the same function- 1 to view the report, 1 to print it, 1 to fax it, and 1 for email.

And, I might add, the array is completely unnecessary, as the checkboxes in the array are available to the code. I guess he was worried that the names of the controls (checkbox1, checkbox2, . . .) weren't very clear- "checkboxes[1]" is much better.

The thing is, if I get to rewrite this (which once again, is what I was hired to do) I'll be able to knock this out of the park with my eyes closed.


Edited by JeffS (16/11/2005 23:32)
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.