FREE FORMAT RPG : BASIC
Free Format RPG was a major step towards the modernization of RPG language. This change in RPG syntax gave RPG programmers flexibility to write code which is easy to type, read and maintain.
Technically Fix Format RPG and Free Format RPG are equally powerful and each one of them has its own pros and minor cons with respect to each other.
|Fix Format||Free Format|
|Almost all syntax checking is done at the time of coding.||Free Format is not that good with Syntax checking.
Compiler do major syntax checking.
For example in Free Format “;” need to be used as end of line character.
If you miss “;” that will give error at compilation time only.
|Not that easy to type as most of stuff need to at their specific location.||Very easy to type like most of Modern programming languages like C and Java.|
|Support both Indicators and BIF for DB IO.||Only support BIF for DB IO.|
|Comments must be start from position 7 using “*”.No inline comment are allowed.||Writing comments are very flexible.
Comments can be started from any position required.
Inline comments are allowed.
Currently as of version 7.X there are two variants of free format RPG
- Free Format RPG: Where only C-Spec is allowed in Free format and all other specifications like F and D specs are still fixed format
- All Free Format RPG: This is the latest change in RPG where all specifications are allowed in free style syntax.
In this series we will talk only about “Free Format RPG” (not “All Free Format RPG”).
When working with Free Format RPG 1st you need to tell compiler that you are going to write free format code.To do this there is a compiler directive “/FREE” and to define the boundary of “/FREE” there is other directive “/END-FREE”.
RPG is not case sensitive so you can write compiler in any case means “/FREE” or “/free” or “/FrEe” every thing is same for compiler.
In next post we will look how to write basic code and comments in free format.