|
>The TYPES of bugs incurred with ITER and LEAVE are more subtle than I want to deal with. My professor in college that taught C was the same way your are. He would rather have 10 IF statements within a loop to make sure code didn't get executed rather than do a BREAK/LEAVE. That made for some ugly code on his part. Since we are about ready for a show down of code, I will start posting some examples (sorry, I am currently working in Java, but you will get the point). . . The first IF statement below will check to see if I want to include this record as part of my results. If I don't, it will just get the next record from the ResultSet. I am curious as to how you would code this without using the CONTINUE keyword while (rs.next()) { if (isNonStoreAccnt(rs.getInt("CORPCONS"), rs.getInt("STORE"))) { continue; } if (firstTime == 'Y') { ...code... firstTime = 'N'; } if (rs.getInt("CORPCONS") != savCorpCons) { ...code... } if (rs.getInt("DIV") != savDiv || rs.getInt("SUBDIV") != savSubDiv || rs.getInt("PRDDIV") != savPrdDiv || rs.getInt("PRDSUBDIV") != savPrdSubDiv) { ...code... } } // End While Loop Here is how my professor would have coded it: while (rs.next()) { if (isNonStoreAccnt(rs.getInt("CORPCONS"), rs.getInt("STORE"))) { continue; } if (firstTime == 'Y' && isNonStoreAccnt(rs.getInt("CORPCONS"), rs.getInt("STORE")) != true) { ...code... firstTime = 'N'; } if ((rs.getInt("CORPCONS") != savCorpCons) && isNonStoreAccnt(rs.getInt("CORPCONS"), rs.getInt("STORE")) != true) { ...code... } if ((rs.getInt("DIV") != savDiv || rs.getInt("SUBDIV") != savSubDiv || rs.getInt("PRDDIV") != savPrdDiv || rs.getInt("PRDSUBDIV") != savPrdSubDiv) && isNonStoreAccnt(rs.getInt("CORPCONS"), rs.getInt("STORE")) != true) { ...code... } } // End While Loop
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.