Books by Bryan Meyers

Programming in RPG IV

Control Language Programming for IBM i

RPG IV Jump Start

Power Tips for RPG IV

VisualAge for RPG by Example

 
The Seven Rules of Free Format RPG Print E-mail

Q. I'm trying to use free format RPG IV, but the editor keeps giving me the following error: The File-Type entry is blank or is not I, O, U, or C. What am I doing wrong?

A. This error is almost always caused by having an invalid entry in positions 6-7 of the free format specification. Contrary to what you might think, there are some positional requirements for free format statements. The irony of having a free format language with specific positional requirements was apparently lost on IBM's language designers.

These seven rules for coding free format RPG IV first appeared in my book RPG IV Jump Start. I've highlighted the positional requirements.

  1. Free form RPG coding begins with a /FREE directive (in position 7) and ends with an /END-FREE (also in position 7). Between these directives, you code free form statement lines.
  2. Free form statements can begin anywhere in positions 8-80; positions 6-7 must be blank. Indenting is allowed.
  3. Free form statements begin with an opcode (and extender, if any), fllowed by Factor 1, Factor 2, and the result field operands separated by blanks. Operands that are not required may be omitted.
  4. Free form statements end with a semicolon (;).
  5. Comments begin with double slash characters (//) and can be placed anywhere on the line starting in position 8. A comment can be code on a line of its own or can follow "inline" after a free form statement.
  6. The portion of a line after the semicolon must be blank or contain an inline comment.
  7. Level indicators, conditioning indicators, and resulting indicators  are not allowed; resulting indicators are replaced by built-in functions.