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



Hans,

The DO operation is NOT upwardly compatible, is it?
I mean, if you say:

C        10      DO          1       Count
C..........
C                EndDO       -1

The loop does not work as expected. You can't count down from 10 to 1.
But the code does compile. So how do this port to FOR?
I don't see how upward compatibility for the DO operation should have
influenced the FOR? FYI, I too was surprised that "FOR X=10 downto 1 by
-1" did not work. So I solve my personal issue, by leaving off the "BY"
clause.
At least you didn't use colons to separate the values! Thank you!


Bob Cozzi
cozzi@rpgiv.com
Visit the new on-line iSeries Forums at: http://www.rpgiv.com/forum

> -----Original Message-----
> From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com]
On
> Behalf Of boldt@ca.ibm.com
> Sent: Wednesday, December 12, 2001 10:06 AM
> To: rpg400-l@midrange.com
> Subject: Re: FOR op-code
>
> Tom wrote:
> >I take your point about breaking existing FOR loops.  That would be
bad.
> >But as far as the syntax making it clear which direction to
iterate....
> The
> >problem is that I must know *beforehand* which direction to loop and
> commit
> >that to code.  Maybe it's that (reaching way back) BASIC showing.
The
> >increment variable should be evaluated once at the beginning of the
loop.
>
> Well, there are lot's of different ways to design a FOR loop.
> Why did we do it that way?  I believe we wanted to provide an
> upward compatible way to convert old-style iterative DO loops
> to an expression-style syntax.  With DO loops, you can change
> increment and limit values on the fly. You're right, probably
> the better design would have the limit and increment computed
> once at the beginning of the loop.
>
> (Actually, FOR is almost completely upward compatible with the
> DO opcode.  One remaining incompatibility should be eliminated
> in the next release of the compiler.)
>
> >An application for this that springs to mind is a READ/READP loop
where I
> >need to get, let's say, the next 10 records or the previous 10
records.
> Say
> >for a page-at-a-time SFL or something similar.
>
> Well, since you have distinct READ and READP operations, you
> still have to know the direction of the loop beforehand
> anyways, right?
>
> Cheers!  Hans
>
> Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com
>
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
> To post a message email: RPG400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
> or email: RPG400-L-request@midrange.com
> 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.