RPG
In the area of programming languages, RPG doesn't have anything to do with role-playing games, but is rather a language introduced by IBM in the 1950s, geared toward punch cards. Its name stands for Report Program Generator.
RPG is designed for batch-processing tasks that churn through all records of a database (such as a list of transactions) and perform some operation on them such as adding them up or outputting them in a report. An unusual quirk of its syntax is that the function of elements of each program line depends on the column number where the element is located within the line - although this is not enforced with newer versions of the IBM i operating system.
'Free-format' RPG has been around for some years now. This allowed code to be written in a more readable way within two compiler directives (/FREE, /END-FREE). For example:
Fixed | Free |
---|---|
If Test = 3 Eval Work = A + B If Work = 1 Eval A = A + 1 Else If Work = 2 Eval B = B + 1 EndIf EndIf Eval C = C – 1 Else Return EndIf |
If Test = 3; Work = A + B; If Work = 1; A = A + 1; Else; If Work = 2; B = B + 1; EndIf; EndIf; C = C – 1; Else; Return; EndIf; |
You should be able to tell that the free-format is easier to read due to the indentation (2 spaces) and also the removal of the eval keyword. There is also free format declarations to look at, which was introduced within the last few years. It allows you to used free-format declarations instead of fixed format. Before 2015, all RPG (whether it be free or fixed format) could only support code between columns eight and eighty. Now the newer compilers allow totally free format code using a **FREE
directive, which also allows code to be written from the first column - with no maximum.