RPG

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m
(Added free-format RPG example)
Line 6: Line 6:
 
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 [[punched card|punch cards]]. Its name stands for Report Program Generator.
 
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 [[punched card|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.
+
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
 +
|-
 +
| <pre>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</pre> || <pre>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; </pre>
 +
|}
 +
 
 +
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.
  
 
== References ==
 
== References ==
 
* [http://en.wikipedia.org/wiki/IBM_RPG IBM RPG (Wikipedia)]
 
* [http://en.wikipedia.org/wiki/IBM_RPG IBM RPG (Wikipedia)]
 +
* [http://www.att.es/archivos/rpgtoolbox_whymovetofreeformrpg.pdf (Why move to Free-Form RPG?)]
  
 
[[Category:IBM]]
 
[[Category:IBM]]

Revision as of 09:47, 9 December 2015

File Format
Name RPG
Ontology
Released 1959

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.

References

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox