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



On Mon, Aug 10, 2015 at 7:54 PM, Dan <dan27649@xxxxxxxxx> wrote:
Thanks Vern. I knew I had seen this type of combo statement before.

Unfortunately, I need variable p in a subsequent statement's %subst
function, so no sense doing two scans per iteration.

Yeah, so you just have to devote a line to assigning p, so you can
reuse the value later.

It often happens that you need two (or more) lines in RPG for common
tasks that seem like maybe they could be squeezed into one. Perhaps
the most basic and common of these is looping over records in a file
without using the built-in cycle.

It always felt a little wasteful to me that a single loop needed two
READx statements (or a CHAIN and a READx). Or, if you were determined
to write the loop with only a single READx statement, then you'd need
an extra comparison (you couldn't rely on the loop's conditional,
because it was in the wrong place; you needed an IF inside the loop to
break out of it). Both of these seem uglier than necessary to me:

setll
reade
dow not %eof
<stuff>
reade
enddo

setll
dow True
reade
if %eof
leave
endif
<stuff>
enddo

Eventually I got over it. I learned to accept that this is how RPG is
built, and these are both probably idiomatic RPG. (I even gave up
using CHAIN with HI indicator at the top and READE with EQ indicator
at the bottom, in favor of being able to use %EOF.)

Another example, back before RPG IV, was getting the remainder of a
division. You had to do the division by itself on one line (often
throwing away the result), then retrieve the remainder on the next. So
clumsy.

Face it, RPG is not made to be concise. It's made to be simple to
implement, simple to write, and simple to read. And I'd say it meets
those goals pretty well.

John Y.

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.