× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



If I get deeper than 3 or 4 nested ifs, I punt and and try to redesign
to avoid it.

only if logic absolutely requires, will I nest dos.

On 9/14/06, Booth Martin <booth@xxxxxxxxxxxx> wrote:
Makes sense to me.

The main benefit of any programming is consistency of structure, for
those that inevitably follow.

My dislike for "leave" is confusion about what it is I am leaving if the
loops are complex or over 13 lines.



rick baird wrote:
>> What is the advantage over:
>>
>> C  dou  cmd3 or cmd12
>>          ....
>>  select
>>  when cmd3
>>  exsr endpgm
>>
>>  when cmd12
>
> no particular advantage except personal preference and style.
>
> I don't like compound and complicated if / do statements. the simpler
> the better. If I add another function that leaves the loop, I have to
> make the do line even more complex.
>
> In the example i gave, only F3 and F12 exit the loop.  But in another
> program I might have another 6 command keys or other conditions who's
> functionality requires that I leave the loop.
>
> That would make my dow look a mess.  Why complicate the dow
> requirements when I can simply put the leave or iter right next to the
> "when" clause that processes it?
>
> If I'm looking at what F17 processing does, and that particular "when"
> section ends with another when, I don't have to page up the top of the
> do to check if that condition ends the loop or not - it's right there
> in front of me, no need to look at the loop.  There also might be code
> after the endsl that gets processed for several of the when groups,
> but none of the iter/leave when groups.
>
> again, it's just personal preference.  imo, smoother, easier to
> understand, no jumping around looking for what happens next.  if it
> "leaves", I find the enddo.  if it "iters" I go to up to the do.
>
> and again, I rarely use this technique outside of my screen processing
> subroutines.   I can take my skeleton and create a simple subfile pgm
> in an hour, and this technique allows me to add complexity to it very
> quickly, without changing the basic structure.  they all look the same
> and work the same.

--
-----------------------------
Booth Martin
www.martinvt.com
-----------------------------
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.