|
Hi Martin, <snip> While I understand the idea of DO *hival coupled with a leave, why not just say it in the first place, and have a DOU F3 and avoid the extra lines of coding? DOU F3 is pretty clear, too, isn't it? </snip> I agree. But in the scenario where there are three different reasons why I would leave the screen loop, each also requiring a separate and distinct action, then I would rather couple the "action" and the "leave" to make it obvious to me. Examples: 1) DOU F3 or someFlag or someOtherFlag or yetAnotherFlag exfmt screen select when F3 // do nothing, just waiting to hit the bottom... when someCondition doSomethingClever() someFlag = *on when someOtherCondition doSomethingEvenMoreClever() someOtherFlag = *on when yetAnotherCondition doSomethingBoring() yetAnotherFlag = *on endsl .some other code... ENDDO 2) DO *hival exfmt screen if F3 leave endif if someCondition doSomethingClever() someFlag = *on leave endif if someOtherCondition doSomethingEvenMoreClever() someOtherFlag = *on leave endif if yetAnotherCondition doSomethingBoring() yetAnotherFlag = *on leave endif .some other code... ENDDO Personally, I prefer the fact that my action and my explicit leave are "coupled". I don't have to look in two places to see why I find myself outside the loop. If I'm having to code for the actions anyway then it's easier (for me) to complete the code with the leave, rather than add another condition on an already overloaded DO. It can't get more obvious to another programmer than code stating "do something then leave". Also, I don't like the fact that I would need a redundant "when" clause for F3. I suppose it boils down to the fact that I consider a screen DO loop as nothing more than a "code container" that has no implicit logic - it's just a construct. I code my exit strategy within this construct. This, of course, does not mean that I code all DO or FOR loops this way. Again, just a preference. Cheers Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 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.