|
Bob wrote: >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? What I meant was that the FOR loop was meant to be largely "functionally" upward compatible with DO. But in this particular case, the conversion is straight-forward: for count = 10 to 1 by -1; ... endfor; and it would work the same way. (That is, the loop would not be performed.) DO only handles upwards iteration. FOR offers the additional functionality of downwards iteration. >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. Why shouldn't compatibility with DO be a consideration? Programmers have embraced and adopted the expression statements in the language. And so that's why FOR came up. By making the FOR largely compatible with DO, RPG III to RPG IV conversion utilities could add this to their repertoire of conversions. But as I suggested, there are a couple of points where FOR is not functionally upward compatible. The first is that you can code an indexed array as loop index in DO, and you can't today in FOR. Because of side issues involved in one particular enhancement we're working on, this might be changed in a future release. (Apart from that specific side issue, I wouldn't have worried about this difference too much.) The other incompatibility is that an index must be coded with FOR. This is easy to get around, though - just code an index. >At least you didn't use colons to separate the values! Thank you! LOL! Lately, I've been playing around with Python. It's a fun language, but the one aspect of Python syntax that often messes me up is I often forget to code the colon! Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.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.