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).
RPG3
DO SAVRRN X
MOVE THIS THAT
X IFGT 10
FIELD1 CAT FIELD2 RESULT
END
END
RPG400
DO SAVRRN X
EVAL THAT = THIS
X IFGT 10
EVAL RESULT = FIELD1 + FIELD2
ENDIF
ENDDO
RPG4
for x = 1 to SAVRRN by 1;
This = That;
if x > 10;
Result = Field1 + Field2;
endif;
endfor;
/me loves some RPG Free format :)
* 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.
