|
John Carr wrote: >Here's your assignment if you chose to accept it, Convert the following >code of that infamous DOU connoisseur guy John Carr to a DOW. >Your score will be judged on Clarity, Brevity, and Succinctness. >To be especially harsh you cannot code the same IF statement >twice(But then, why should you need to?). > No problem John: KEY CHAIN FILEXXX 90.... *IN90 DOWNE *ON XXXCODE ANDNE 'B' XXXCODE CASNE 'A' @@PROC ENDCS KEY READE FILEXXX ....90 ENDDO @@PROC BEGSR < ... end of in-line edits ...> <.... whatever process ....> ENDSR It takes less code (9 lines versus 13 lines), is easier to read, and does not require the redundant indicator test *IN90 IFEQ *ON/LEAVE/ENDDO at the start of the loop. Nor does it require an implied GOTO with a LEAVE or ITER which refers to an ENDDO which might be found after an intense and frustrating search many pages later in the code. It also separates the logic unrelated to the loop processing into a separate subroutine. Moreover, in your sample, if you use Indicator 90 inside your DOU loop, the loop fails. When you use a primed read loop, the indicator used on the DOW or DOU can be used within the loop without a problem since it is always reset immediately before the ENDDO. You owe me a drink at CUDS. Original code sample was as follows: > KEY SETLL FILEXXX > *IN90 DOUEQ *ON > KEY READE FILEXXX 90 > *IN90 IFEQ *ON > LEAVE > ENDIF > > XXXCODE IFEQ 'B' > LEAVE > ENDIF > > XXXCODE IFEQ 'A' > ITER > ENDIF > < ... end of in-line edits ...> > > <.... whatever process ....> > > ENDDO Charlie Massoglia, Massoglia Technical Consulting, Inc. PO Box 1065, Okemos, MI 48854, USA 517-676-9700 Fax: 517-676-1006 EMAIL: cmassoglia@voyager.net * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 MAJORDOMO@midrange.com and specify * * 'unsubscribe MIDRANGE-L' in the body of your message. Questions * * should be directed to the list owner / operator: david@midrange.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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.