× 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.


  • Subject: Re: what is unclear - LEAVE
  • From: Jeff Gunter <JeffGunter@xxxxxxxxxxxx>
  • Date: Mon, 11 May 1998 19:22:21 -0500

I don't want to beat this to death, but Simon's last example could be further simplified (I know... so what?) and I think be just as clear as follows:

C        DO
C        READ   FORMAT             90
C  90    LEAVE
C     <<DO STUFF>>
C        ENDDO

Believe me, I don't want to restir the conditioning indicator pot again, but in this case, I think it is pretty clear its purpose.  Control of the section of code is clearly associated with the activity (READ).  This isn't pure structured code, but it reads well.

--
Jeff Gunter
IBM Certified Specialist - AS/400 RPG Programmer
_______________________________________
Visit my Web Site at:

http://www.as400guy.com/
 
 

Simon Coulter wrote:

Hello Paul,

The priming read isn't sloppy; it's a standard design pattern.  It avoids the extra IF test (inside the loop) to
cope with EOF which means half as many tests in your loop construct.  For example:

C       *IN90   DOUEQ   *ON
C               READ    FORMAT                                  90
C       *IN90   IFEQ    *OFF
 *              do stuff
C               ENDIF
C               ENDDO

Of course many of the list members would code that as:

C       *IN90   DOUEQ   *ON
C               READ    FORMAT                                  90
C  90           LEAVE
 *              do stuff
C               ENDDO

But you still get the unnecessary extra test.

I used to code this way until I measured the cost of the extra tests over millions of records.  Changing to the
the priming read and a DOW saved many minutes in a job where those saved minutes counted.  Now it's habit.

Regards,
Simon Coulter.

//----------------------------------------------------------
// FlyByNight Software         AS/400 Technical Specialists
// Phone: +61 3 9419 0175      Mobile: +61 3 0411 091 400
// Fax:   +61 3 9419 0175      E-mail: shc@flybynight.com.au
//
// Windoze should not be open at Warp speed.
 

//--- forwarded letter -------------------------------------------------------
> Date: Thu, 07 May 98 21:51:11 -0400
> From: "PaulMmn" <PaulMmn@ix.netcom.com>
> To: MIDRANGE-L@midrange.com
> Reply-To: MIDRANGE-L@midrange.com
> Subject: Re: what is unclear - LEAVE

>
> >(BTW, my preference is a DOW with a priming read, and a read at the bottom
> >of the loop)
> >
> >Regards,
> >
> >Rick
>
>
> It's always struck me as sloppy coding to require 2 reads for the same
> file...   (:  I'm not really sure of what logic I like to eliminate this
> 'priming read,' but I know I don't like that extra read.
>
>
> --Paul E Musselman
> PaulMMn@ix.netcom.com

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

 
 
 

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.