I am sure that I have confused readers with the names I call the different flavors of free format RPG. I thought it would be best to have a post where I describe each flavor, and then refer the reader to this post from others when I need to explain the differences.

Before I start I just want to explain that these are the names I call the different flavors. These might not be (probably definitely not) the names that IBM would call them, but I do call them this.

In my opinion there are three flavors of free format RPG:

ILE RPG, RPGIV, or RPGLE was introduced by IBM as part of V3R1 in 1994. It still had a column centric format, but the EVAL operation code, with its "extended factor 2", gave us a foretaste of what free format could look like.

FINVMST IF E K DISK D wkCorp S like(CORPNO) inz('100') D wkInvoice S 10 C klist1 klist C kfld wkCorp C kfld wkInvoice C eval wkInvoice = 'I035552120' C klist1 chain INVMSTR C if (%found) C endif C eval *inlr = *on

Free form calculations

Seven years later, 2001, came the first free format flavor. V5R1 came with RPG free format calculations. All I had to do was insert /FREE and I could write all of what had been Calculation specifications in free format code. Alas, some of the functionality that had been available in the fixed format was not available in the new free format. Fixed format code could be inserted amongst the free just by placing a /END-FREE on the line before the fixed format line, and a /FREE on the line after to return to free format. The flipping in and out of free format code became a pain-in-the-neck when coding procedures, and I am sure this dissuaded many from adopting them.

While the free format code was not columnar, like the fixed format specifications, it was limited to where it could be in the source code. It could not start before the eighth column, and not extend beyond the 80th.

FINVMST IF E K DISK D wkInvoice S 10 /free wkInvoice = 'I035552120' ; chain ('100':wkInvoice) INVMSTR ; if (%found) ; endif ; *inlr = *on ;

Free format definitions

It made sense for the next development in free format was to make the definition specifications free. That came in a PTF that accompanied IBM i 7.1 TR7, in November 2013. This liberated the Header, File and Data definition specifications. It is interesting that the Input and Output specs were not freed, I think this is IBM saying that we need not to stop using them. It did away with the /FREE , allowing me to easily intermingle free and fixed format code.

I have written extensively about free format definitions and the other changes in the posts listed below.

Alas, even though those specifications were freed I still could only code them between the eighth and 80th columns.

...+... 1 ...+... 2 ...+... 3 ...+... 4 dcl-f INVMST keyed ; dcl-s wkInvoice char(10) ; wkInvoice = 'I035552120' ; chain ('100':wkInvoice) INVMSTR ; if (%found) ; endif ; *inlr = *on ;

Totally free form

The final act of liberation came in November 2015 in IBM i technology refreshes 7.2 TR3 and 7.1 TR11. Now I could start my free format RPG code in the first column and, if I want to "go all the way" I can go to the 240th column! All I have to do is to have **FREE starting in the first column to inform the compiler I am going totally free.

Alas, by going totally free form I lose the ability to easily insert fixed format code amongst the free format. There is a way to do it, I am not going to explain how to do it here as I have written about it in the post linked below:

...+... 1 ...+... 2 ...+... 3 ...+... 4 **free dcl-f INVMST keyed ; dcl-s wkInvoice char(10) ; wkInvoice = 'I035552120' ; chain ('100':wkInvoice) INVMSTR ; if (%found) ; endif ; *inlr = *on ;

Jon Paris, IBM i guru, wrote six articles accounting the evolution of free format. As he was involved in the process it is interesting to have the chance to peek behind the curtain to see why it took IBM so long to give us totally free format. His post here provides links to all six parts in one place.