|
Hans, 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. 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. Tom | -----Original Message----- | From: boldt@ca.ibm.com [mailto:boldt@ca.ibm.com] | Sent: Wednesday, December 12, 2001 09:13 | To: rpg400-l@midrange.com | Subject: Re: FOR op-code | | | >But since we're on the subject of | >wish-lists... | | >I wish the FOR op-code did away with the TO/DOWNTO and | instead looked at | the | >sign of the BY increment. There would also have to be a | change in the way | >the limit value and the index are compared. | > | >So that I can fill an array 'forwards' or 'backwards', for | instance. | This | >seems more 'natural' to me. | | Since that might cause existing FOR loops to behave differently, | this isn't going to happen. With the current syntax, it is clear | exactly which direction the loop interates. | | One problem with the proposal is what happens when the sign of | the increment variable changes during the looping? The limit | test would also change sense, and would likely cause the loop | to exit earlier than expected since the index value would now | be on the other side of the limit value. | | 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 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.