Site icon AS400 ISeries

RPGLE Free Format (Hello World)

Today RPGLE supports fully free formatting. It is similar to other languages such as JAVA, PHP and can be understood easily. Programmers who are familiar with other modern languages can more learn RPGLE.

There are numerous advantages in Free Format RPGLE over legacy fixed format.

Advertisements

Differences between Free Format vs Legacy Fixed Format

RPG has two modes of free-form code. The historical/legacy mode (column-limited mode) requires that all free-form code must be coded between columns 8 and 80. Fully-free mode allows free-form code in any column, with no limit on line-length.

Fully free-form source must have **FREE in column 1 of line 1. All the code must be free-form.

Non-fully-free source, or column-limited source does not have **FREE in line 1. You can mix fixed-form code (code that uses columns 6 and 7) and free-form code in column-limited source.

This tutorial assumes you have **FREE at the beginning of your source, but it also works if you use column-limited source, if you ensure that columns 1-7 are blank and that you don’t go past column 80. The examples have 7 blanks at the beginning to make it easy to copy and paste into column-limited source, but if you have **FREE at the beginning of your source, you can remove those blanks if you like.

Lets try a small hello world example in Free Format RPGLE.

Create a member “helloworld” in your working source physical file. Give the type of this member as “RPGLE”. Now type the following code in the source member.

RPGLE FREE FORMAT (Hello World)

No need to worry about positioning like we did on Fixed format RPGLE. But remember to use semicolon (;) at the end of each line.

Now compile the module. Create the program and call it, It Will display the phrase Hello World.

Compile the program

Advertisements

Run RPGLE Free Format (Hello World)

Exit mobile version