RPGLE

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...

Written by AS400i · 1 min read >

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

  • If you are using RDi, you can compile from the menu within the editor, or you can save your changes and compile by right-clicking on the member in the navigation. Either way, select the CRTBNDRPG command, and take all the defaults.

  • If you are using SEU, exit the editor by using F3, and compile by using option 14. You could also compile from the command line by using the CRTBNDRPG command, and by using F4 to prompt the command.
Advertisements

Run RPGLE Free Format (Hello World)

  • Use the CALL command to call the HELLOWORLD program, substituting the name of your library for yourlibrary.===> CALL yourlibrary/HELLOWORLD

  • It puts up a message saying “DSPLY Hello World

  • Just press ENTER to end the program.

One Reply to “RPGLE Free Format (Hello World)”

why dont you add your experience here

%d bloggers like this: