You are currently on IBM Systems Media’s archival website. Click here to view our new website.

IBM i > DEVELOPER > RPG

Happy Free RPG Day!


In doing some online research for this article, we ran upon a link for “Free RPG Day.” Turns out, they were talking about role-playing games—not our own beloved RPG. But it seemed appropriate to steal the title. Why? Because just a few days ago, we had our own “Free RPG Day.”

On October 7, IBM announced freedom for H, F, D and P specs in RPG—no more columns. Perhaps even better, we can now be completely free from /Free (and /End-Free). This new (almost) completely free format RPG is available with Technology Refresh 7 (TR7) of V7.1. We say “almost” because there is still no freedom for the I and O specs, but with the exception of the occasional program-described report, we haven’t used those specs in years anyway so it’s not really a hardship.

If by chance you’ve been living with your head in the sand for 10 years or so and you missed out on the capability to write RPG logic without columns, you can catch up on the details of that part of free-format RPG here. Most RPGers we talk to have switched to free format logic, at least for their new code. And many, having noticed how much easier it is to read and maintain the code in that form, have—with the help of some third-party tools—even converted their old logic to free format.

While free-form calculations were a huge improvement, we were still stuck with those pesky columns for F, D and P specs. Even that wouldn’t have been so bad—after all most experts advise to line up definitions in columns when coding in C++, PHP, Java and other modern languages. However, those of us who latched onto using subprocedures to replace subroutines had to live with coding /End-Free and /Free repeatedly to allow for the P and D specs. Very annoying.

But RPG is bound by columns no more! Let’s take a look at the syntax for this new fully free RPG.

The Syntax

Recall that free format logic statements all begin with an operation code (op code) and end with a semicolon (;). The same is true for the new free format H, F, D and P specs. What? An op code for F and D specs? What’s that?

Replacing the spec letter is an op code based on the type of spec we’re replacing. To replace an H, the op code is CTL-OPT. To replace the F, D or P specs it is a DCL-xx (declare) operation code, where “xx” represents the type of declaration. In the following list of DCL-xx operations, unless otherwise specified, the spec type being replaced is D.

DCL-F for a file (replacing the F spec)
DCL-S for a stand alone field
DCL-DS for data structure
DCL-C for a named constant
DCL-PR for a prototype
DCL-PI for a procedure interface
DCL-PROC for a procedure (replacing the P spec)

Probably no surprise to anyone, these op codes begin the declaration and require a corresponding ending op code for most of them, such as END-DS, END-PR, END-PROC, etc.

This new free format compiler is now a bit more laid back about a few things.

We can now intermix free format operations with fixed format (columnar) operations even without the use of /END-FREE and /FREE. Any source line with a blank in columns 6 and 7 and not blank in columns 8 to 80 (still the boundaries of RPG code) will be treated as free format. Any source line that is not blank in both 6 and 7 will be treated as fixed format. Don’t worry—you don’t need to rush in to remove all your /FREE and /END-FREE statements; they will be ignored.

We can now intermix our file declarations and our (other) data declarations. This is even true for the fixed format F and D specs. This will allow you to physically code the file declaration together with the data structure populated from that file, for example. This is a nice capability that also benefits those who choose to retain their fixed form ways.

Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.



Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters