Doing Loop the Loops in RPG3 and RPG /Free
So, whenever possible, if I'm editing some old RPG3 or RPG400 code I spend a coffee* cleaning the code up to a more readable form:
- Use CVTRPGSRC if its old RPG3 stuff
- Change '1' to *ON
- Change '0' to *OFF
- Change Z-ADD to EVAL
- Insert comments where applicable
- put some spaces between subroutines and blocks of functionally similar code
- Then its into WDSC7 and convert to /FREE
Websphere is old technology but I'm not going to spend over $800 on IBM's Rational Developer for i version... c'mon IBM come up with a sensible price for a source code editor. Obviously, the most sensible is FREE.
DO LOOPS are something that sometimes make me scratch my head when uplifting to RPG4. So just for my reference here is an example of the exact same code in RPG3, RPG400 and RPG4 (or RPG ILE as its sometimes called).
DO SAVRRN X MOVE PLOP THING X IFGT 10 FIELD1 CAT FIELD2 RESULT END END
DO SAVRRN X EVAL THING = PLOP X IFGT 10 EVAL RESULT = FIELD1 + FIELD2 ENDIF ENDDO
RPG4 - also known as RPGLE /FreeFormat
For x = 1 to SAVRRN by 1; Thing = Plop; If x > 10; Result = Field1 + Field2; Endif; EndFor;
/me loves some RPG Free format. It makes this lovely old RPG language readable and slinky :)
* A 'coffee' is the amount of time it takes to drink a regular cup of brew. This is slightly shorter than the English standard time unit of a 'tea' because that also has 'biscuits' multiplied by 'dunk' to take into consideration.