Free-Format RPG IV: The Express Guide to Learning Free Format - Softcover

Martin, Jim

 
9781583474136: Free-Format RPG IV: The Express Guide to Learning Free Format

Inhaltsangabe

Focusing strictly on teaching free-format RPG programming methods, this book will help programmers wishing to upgrade their skills
 
This how-to guide offers a concise and thorough introduction to the increased productivity, better readability, and easier program maintenance that comes with the free-format style of programming in RPG IV. Although free-format information is available in IBM manuals, it is not separated from everything else, requiring hours of tedious research to track down the information needed. This book provides everything you need to know to write RPG IV in the free-format style. Author Jim Martin not only teaches rules and syntax, but also explains how this modern style of coding has the potential to improve overall programmer productivity&;from initial development through maintenance. He methodically covers the many style issues, such as named indicators and built-in functions, and addresses topics including input and output, program flow, data manipulation, math operations, prototyping, and APIs. This third edition is updated to V7.1 of the IBM i operating system on IBM Power machines. An added chapter explains the new free-format H, F, D, and P specifications introduced by IBM in Technology Refresh 7, and programming examples throughout the book are updated to reflect the new specifications.

Die Inhaltsangabe kann sich auf eine andere Ausgabe dieses Titels beziehen.

Über die Autorin bzw. den Autor

Jim Martin was employed by IBM for 26 years writing RPG applications and programming portions of CPF and OS/400 in the programming laboratory. He is an IBM-certified RPG IV developer and the author of the bestselling first and second editions of Free-Format RPG IV as well as Functions in Free-Format RPG IV. He lives in Springfield, Missouri.

Auszug. © Genehmigter Nachdruck. Alle Rechte vorbehalten.

Free-Format RPG IV

By Jim Martin

MC Press Online, LLC

Copyright © 2015 Jim Martin
All rights reserved.
ISBN: 978-1-58347-413-6

Contents

Preface to the Second Edition,
A Note About Source Entry,
Chapter 1: Pre-Free-Format RPG IV,
Chapter 2: The Case for Free-Format RPG,
Chapter 3: Free-Format H, F, D, and P Specifications,
Chapter 4: Introducing Free-Format RPG IV,
Chapter 5: Input/Output Using Free Format,
Chapter 6: Program Flow Using Free Format,
Chapter 7: Embedded SQL Operations Using Free Format,
Chapter 8: Data-Manipulation Operations Using Free Format,
Chapter 9: Math Operations in Free Format,
Chapter 10: Call and Return in Free Format,
Chapter 11: Solutions for Problem Situations,
Chapter 12: Sample Programs,
Appendix A: Free-Format Operations,
Appendix B: Example Screens, DDS, and Programs,
Appendix C: Free-Format Alternatives for Fixed-Format Operations,
Index,


CHAPTER 1

Pre-Free-Format RPG IV


The RPG programming language has certainly come a long way since its introduction as a simple report program generator in the 1960s. From the earliest versions of RPG to the latest release of free-format RPG IV on the IBM® Power® platform, the changes have been dramatic.

The centerpiece of today's RPG is its support for a free-format style of coding. Free format puts RPG on the map of modern programming languages and gives programmers important functionality for constructing programs that are easier to create, understand, and maintain. If you are writing RPG programs today, you owe it to yourself to make the most of this great function.

In this book, you will learn the ins and outs of free-format RPG, from coding file definitions, data structures and other definitions, I/O, and program flow to data manipulation, math operations, and call and return. But before we dive into the delights of free-format RPG, let's take a brief look at its precursor: fixed-format RPG IV.


RPG IV

Even before free format, RPG IV was a powerful, functionally rich programming language. RPG IV — or ILE RPG, as it is officially known — debuted in late 1994 with Version 3 Release 1 (V3R1) of the IBM i® operating system. IBM had introduced the Integrated Language Environment® (ILE) in a prior release, but everyone eagerly awaited RPG's entrée into ILE. Three major additions to RPG in V3R1 brought the language a significant level of sophistication that was absent before: the extended Factor 2, built-in functions, and subprocedures.


Extended Factor 2

The introduction of the extended Factor 2 format, along with operations to exploit it, represented a huge departure from RPG's past. With this enhancement to calculation specifications, RPG programmers could now use operations such as Eval (Evaluate expression) and If (If) with long expressions.

The ability to use math symbols (+, -, *, /) within expressions was a major step in modernizing the language. Other symbols, used in comparison expressions, included equal (=), less than (<), greater than (>), less than or equal (<=), greater than or equal (>=), and not equal (<>). The exponentiation symbol (**) became the newest math operator, and support for parentheses let programmers indicate higher precedence in math or comparison expressions. Other programming languages had used these symbols for a while, and IBM chose to bring them into its new version of RPG.

One of the symbols, the plus operator (+), also found another use in RPG IV: concatenation. Using this new operator, programmers could put character data together into strings much more easily than with previous methods.


Built-in Functions

Programmers were already familiar with built-in functions through their use of such functions in OS/400 Control Language (CL). The %Sst (Substring) and %Bin (Binary) functions, for example, are commonly used CL built-in functions.

The whole idea of an RPG IV built-in function was based on the C language function idea. A built-in function performs one task, with or without parameters, and usually returns data of a predetermined data type to the point in the program where the function was specified. For example, RPG IV's %Eof (End-of-file) built-in function checks for end of file after a Read operation, eliminating the need to code a resulting indicator on the Read. The %Found built-in function lets you check for a record-found condition after a Chain operation without using a resulting indicator.

The number of built-in functions available in RPG, as of V7.1 of IBM i, has grown from the dozen or so in RPG IV's initial release to 80 now. Many of these built-in functions duplicate the function of older operation codes, such as Scan (built-in function %Scan) and Substr (built-in function %Subst). In some cases, the built-in function provides more capabilities than the operation code it replaces. For example, the %Subst (Get substring) built-in function can substring a target string as well as a source string, whereas the Subst operation code can substring only a source string.


Subprocedures

As if these new capabilities weren't enough, IBM added another big feature to RPG IV. Subprocedures give RPG IV programmers the option to break complex programs into smaller parts and to create "homegrown" built-in functions if desired. For the first time in RPG, the concept of a "local" variable was introduced for use in subprocedures. Also for the first time, a routine — in this case, a subprocedure — was able to use recursion.


Other Changes

In RPG IV, IBM also eliminated many of the old constraints of RPG IV's predecessor, RPG/400®. Eight-character file and record names were lengthened to 10. Field names were lengthened, too — at first to 10 and then to 4,096! The maximum size of character fields was enlarged from 256 bytes to 16 megabytes! Packed numeric field length size was raised to 30 and then 31 digits; it now stands at 63.

Even fans of binary and hexadecimal programming were given something new in RPG IV. Previously, you could convert two-byte binary numbers to four-digit decimal numbers and convert four-byte binary numbers to nine digits. The new RPG IV language provided an integer data type, both signed and unsigned, up to 20 digits. To handle ultra-small and ultra-large numbers, the floating-point data type made its debut, in both standard and double precision.

Other data types added to the language include the pointer data type, which contains the address of data or a procedure; the date, time, and timestamp data types; and the object data type, used to handle references to a Java® object.

Adding these new data types and enlarging the older ones must have come from some larger motivating factor. Why did IBM provide all these things? In my opinion, the reasons lie in maintaining the Power system as a modern and viable solution for the midrange server marketplace. Older RPG can easily be called a "dinosaur" in this modern age. The gap in programming capabilities between older RPG and modern languages such as C, C++, Java, and others is huge. With today's RPG IV, there is no gap. RPG IV has "come from behind" to be a major player in the modern world of application development.


Some "Baggage" That Came Along

Like any responsible vendor, IBM doesn't like to offend any of its customers. If you wrote an RPG program in 1969 that used the RPG cycle and 99 indicators, IBM won't tell you that...

„Über diesen Titel“ kann sich auf eine andere Ausgabe dieses Titels beziehen.

Weitere beliebte Ausgaben desselben Titels

9781583474143: Free-Format RPG IV: The Express Guide to Learning Free Format

Vorgestellte Ausgabe

ISBN 10:  1583474145 ISBN 13:  9781583474143
Softcover