The Modern Rpg IV Language: Fourth edition - Softcover

Cozzi, Robert

 
9781583470640: The Modern Rpg IV Language: Fourth edition

Inhaltsangabe

Cozzi on everything RPG! What more could you want?
 
In this fourth edition of The Modern RPG IV Language, internationally recognized RPG expert Bob Cozzi takes his classic best seller to a whole new level. At close to 700 pages, this edition covers all of the new functions and facilities available in V5R4 RPG IV while keeping the straightforward, no-nonsense style that has kept this book on the best-seller list for almost 20 years. This new edition is guaranteed to keep Bob Cozzi as the leading expert on RPG, and his book the one turned to by countless developers worldwide.

This new edition of The Modern RPG IV Language is packed with new information including new, never-before published information on coding free-format RPG IV. Chapter 12 delves into free-format in detail as he discusses MOVE alternatives, date and time conversions, data structures, and more. And to give you even more exposure to free-format, he has converted many of the examples throughout the book to free-format code. Add to that XML, CGI, and subprocedure information, and you have a book that no "modern" RPG programmer can be without.
 
Even with all the new material, the basic concept of the book remains the same. As with previous editions, The Modern RPG IV Language, 4th Edition takes you through RPG IV, from its foundation to its most advanced techniques. At the core of this book are its chapters on built-in functions and op codes. In these chapters, Cozzi details each built-in function and op code with syntax tables that give you all the information you need at a glance plus examples to help you as you code.
 
This is much more than just a book on rules, however. Bob includes more than 400 charts and tables to show how those rules apply and provides more than 500 real-life code examples of functions and operations. You&;ll turn to this book again and again as you program in RPG IV. It is the quintessential reference for every RPG programmer.

What's New in This Edition?

> Free-format syntax, including an entire chapter focused on this highly popular subject
> Free-format examples throughout the book
> Expanded information on subprocedures XML support, including new BIFs and op codes
> Web programming with RPG, including CGI APIs and URL encoding
> Updated and revised content throughout the book to cover i5/OS V5R4

Within the pages of this book, you will find:

&; The basics of RPG IV, including data types, indicators, constants, and directives
&; Detail on all of the specification types
&; A complete discussion of expressions and how they should be used
&; Every built-in function
&; Every op code
&; Options for organizing your program with source files, modules, and storage
&; A discussion on modern operation code optimization
&; An explanation of structured programming and how to apply it effectively in RPG
&; Instructions on how to code inter-module communications
&; Everything you need to know about procedures
&; An entire chapter on the alternate syntax options now available&;most notably Free-Format

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

Über die Autorinnen und Autoren

Bob Cozzi is an RPG programmer and the author of several books on programming. He is also the author of MC RPG Developer, a free email publication.


Bob Cozzi is an RPG programmer and the author of several books on programming. He is also the author of MC RPG Developer, a free email publication.

Auszug. © Genehmigter Nachdruck. Alle Rechte vorbehalten.

The Modern RPG IV Language

By Robert Cozzi Jr.

MC Press

Copyright © 2008 Robert Cozzi, Jr.
All rights reserved.
ISBN: 978-1-58347-064-0

Contents

Title Page,
Copyright Page,
Dedication,
ACKNOWLEDGMENTS,
PREFACE TO THE FOURTH EDITION,
Chapter 1 - INTRODUCTION,
Chapter 2 - SPECIFICATION FORMATS,
Chapter 3 - EXPRESSIONS,
Chapter 4 - BUILT-IN FUNCTIONS,
Chapter 5 - OPERATION CODES,
Chapter 6 - PROGRAM ORGANIZATION,
Chapter 7 - MODERN OPERATION CODE USAGE,
Chapter 8 - STRUCTURED PROGRAMMING,
Chapter 9 - INTER-MODULE COMMUNICATION,
Chapter 10 - PROCEDURES,
Chapter 11 - FILE PROCESSING,
Chapter 12 - ALTERNATE SYNTAX OPTIONS,
Chapter 13 - WEB PROGRAMMING INTERFACES,
Appendix A - COMPILER OPTIONS,
Appendix B - DECIMAL DATA ERRORS,
Appendix C - DDS DATE AND TIME FORMAT CONSIDERATIONS,
Appendix D - SOURCE CODE LISTINGS,


CHAPTER 1

INTRODUCTION

RPG is both a position-oriented and free-format language. This means that certain information, such as control codes and field names, must be placed into specific positions of the RPG program statements. Failure to fulfill this obligation results in an error message. The free-format component of RPG IV is supported in the procedure area (known as the calculation specifications) and to a lesser extent in a keyword area of the data definition.

In a free-form procedure language such as COBOL, the value of one variable (or "field") can be copied to another by specifying the following statement:

MOVE FIELDA TO FIELDB

Most high-level languages use the MOVE instruction to copy data. There is no documentation as to how this tradition started, but it's taken for granted now. The preceding COBOL statement copies each character from the memory location of the first field, FIELDA, to the memory location of the second field, FIELDB.

The same program statement written in C or C++ might look like this:

strcpy(fieldbm fielda);

In traditional RPG programs, the same program statement looks like this:

[PROGRAM LISTING NOT REPRODUCIBLE IN ASCII]

Using free-format RPG IV commands, the same program statement could look like this:

[PROGRAM LISTING NOT REPRODUCIBLE IN ASCII]

Or like this:

[PROGRAM LISTING NOT REPRODUCIBLE IN ASCII]


The three forms of RPG IV statements shown above are referred to as fixed format, columnar expression format (sometimes called "hybrid free -format"), and free format. The first two styles of coding are referred to as "Traditional RPG IV" and the third style is often referred to as "/free" or "free -format." This is because the free-format style was added much later in the life of RPG IV. The field being copied (FIELDA) is referred to as the source field. The field that receives the data is referred to as the target or result field.

The MOVE and EVAL instructions appear in positions 26 through 35. These positions contain the program instruction or operation code. The operation code is commonly referred to as operation or opcode.

The letter "C" must appear in position 6 of RPG "Calculation" statements, except when using free-format; in that case position 6 must be blank. Different letters are used to identify the various types of program statements (or specifications). The available specifications are:

* Header specification. * File specifications. * Definition specifications. * Input specifications. * Calculation specifications. * Output specifications. * Procedure specifications.

Ordinarily, an editor is available that provides prompting for "fill-in-the-blank" coding of the different RPG specifications. Consequently, programmers need not be concerned with remembering specific positions. However, a thorough knowledge of the various specification types and their layout will greatly improve programmer efficiency.

Another example of the position-oriented structure of RPG follows. Suppose three account totals need to be accumulated. In a free-format procedure language such as PL/I, the program statements look like the source code shown in Figure 1.1.

In traditional RPG, the equivalent program looks like the code shown in Figure 1.2.

In this example, the IF operation is used to compare the field ACCT to three numbers, and then the value of the field AMOUNT is added to one of three total fields.

RPG requires an associated ENDIF operation for each IF operation. This is because IF operations are treated as an IF-THEN-DO structure. This allows several statements to be conditioned and performed for each IF operation. As a by-product, the program's complexity is reduced. However, when IF statements are nested too deeply (usually more than three levels deep) the program's readability is reduced. Readability can be improved greatly, however, through the use of an in-line case structure. RPG support two forms of in-line case. The first is the SELECT-WHEN operations. The source code shown in Figure 1.2 — rewritten using the SELECT-WHEN operations — is illustrated in Figure 1.3a.

The second form of in-line case is the IF statement itself. However, later versions of RPG include a new ELSEIF operation that eliminates the need for multiple ENDIF statements. The source code shown in Figure 1.2 — rewritten using the SELECT-WHEN operations — is illustrated in Figure 1.3b.

The primary difference between these three examples is readability. The SELECT-WHEN requires only one ENDSL statement for the entire case group. The IF/ELSEIF style also requires only one ENDxx statement. The SELECT-WHEN operations are available on all versions of RPG, whereas the IF/ELSEIF option (Figure 1.3b) is only available on later releases of RPG.


POSITION-ORIENTED PROGRAM SPECIFICATIONS

To simplify writing RPG programs, various preprinted specification forms are available. These forms allow an application program to be written while making certain the correct positions are used. The source statements that make up an application program are transferred to the computer for compilation. This process,known as desk coding, was very popular before the onslaught of desktop personal computers, with their full-screen editors, as well as the full-screen editor available with the OS/400 operating system.

Very little desk coding is done any longer. Programmers usually write pseudocode (a free-format, English-like, logic-based language that is not compiled). The pseudocode is translated, by hand, into a high-level language. Pseudocode strongly resembles PL/I. When translating pseudocode into a high-level language, such as RPG, a full-screen editor or integrated development environment (IDE) is used to provide a more productive environment with fewer typing errors. This can result in fewer errors being placed into the source program.

Several full-screen editors are available to the RPG programmer, including CodeStudio, a GUI Microsoft Windows-based IDE for RPG and DDS; SEU, the source editor that comes with OS/400; and the GUI-based IDE offered by IBM. These source-code editors provide prompts that allow RPG program statements to be written easily. The editors correctly format the program statement to match the RPG specification.

A programmer with experience writing RPG programs using 80-position cards on an IBM 029 or 129 keypunch machine will appreciate using an online, full-screen editor or IDE that checks the syntax of...

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