What I call totally free RPG and what IBM calls modern RPG has been around for nine years. This type of RPG always needs the **FREE directive starting in the first position of the source line. And what follows is the free form RPG, where the source line can start in any position.
...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 01 **free 02 dcl-s Statement1 varchar(100) inz('Entered in free format RPG') ; |
Marc Raynor informed me of another directive that "ends" the free format RPG, **END-FREE. After that directive all valid RPG must be entered in the sixth position for fixed format code, and later for the not completely free format code.
Having been told this I had to try it:
...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 01 **free 02 dcl-s Statement1 varchar(100) inz('Entered in free format RPG') ; 03 **end-free .....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++++++ 04 D Statement2 S 52 inz('Entered in fixed format RPG') 05 **free 06 dsply Statement2 ; 07 return ; |
Line 1: Is the **FREE directive, which starts in the first position of the source statement.
Line 2: The definition of a variable in free format RPG.
Line 3: The **END-FREE directive.
Line 4: A fixed format definition specification, D-spec, to define a variable.
Line 5: Another **FREE directive to inform the RPG compiler that more totally free format code will follow.
Line 6: A free format Display operation code to display the contents of the variable defined in the D-spec.
The above RPG code compiles, and when call it works as I expect.
Prior to Marc's communication I was unaware of the **END-FREE directive. I cannot find reference to it in the RPG Reference Manual for both IBM i 7.4 and 7.5 .
I think it is only fair to include Marc's comments on how he found this, and how he thinks it should be used:
It's very useful if you have old programs and you want to have some free format code that extends beyond position 80. You can use **free and **end-free in the same way as the old /free /end-free except that is fully free format. I discovered this by using the compiler preprocessing option that brings in /INCLUDES into an interim source member. When I looked at it it had inserted **end-free so that it could still use the old D an C specs.
Thank you Marc for sharing this discovery with me, so that I can share it with all of you.
We found out about **END-FREE close to when **FREE became available on our system. Then we were told that it was a special IBM value used to allow for older copybooks to be used with **FREE source and was not documented for a reason. We were warned to not rely on using this special code going forward. I think documenting it would give too many code shops another reason to lag behind on improving tech.
ReplyDelete-Matt
I really wish you hadn't publicized this Simon. As Anonymous said - it was required for IBM internal use (the pre-compiler couldn't keep up). It is not docuemented for a reason and should not be used.
ReplyDeleteThere is something I like about kaos, the no naming things behavior!
ReplyDeleteSince RPG II(never used) and RPG III (System/38), RPG was improved in order to be more flexible. Then ILE appears, changing at least 3 things: the evolution to RPG IV, the half free dialect, and the full free form.
The full free form is the "modern RPG". But for me is "THE" RPG V, almost nothing to do with his far and old parent!