O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Functions in Free-Format RPG IV

Book Description

Here is the ultimate guide to writing RPG IV programs with functions in the free-format style. Let RPG expert and best-selling author Jim Martin show you the way. Want to generate a random number, manipulate a character string, or determine the number of elements in a data structure? There's a function for that. Jim will even show you how to write your own custom built-in functions (BIFs). In this book, you'll discover the role of functions in free-format RPG IV. Jim explains the details of built-in functions (BIFs) and explores the use of C language functions, do-it-yourself functions (subprocedures), and prototyping and procedure interfaces for function connectivity of RPG IV main procedures with subprocedures and other modules. Because functions rely heavily on ILE, the book examines those ILE concepts that connect the parts of a multi-functional program, such as binding, import/export of data, service programs, and binding directories. In addition, you'll find how to prototype IBM's APIs.

Table of Contents

  1. Copyright
  2. Dedication
  3. Acknowledgements
  4. Preface
  5. An Introduction to Functions
    1. What Is a Function?
    2. Functions vs. Operation Codes
    3. Return Values
    4. Function Parameters
    5. Summary
  6. Essential BIFs in Free-Format RPG IV
    1. Different Uses for Built-in Functions
    2. BIFs Used in Definition Specifications
    3. BIFs in a Procedure, by Return Value
    4. BIFs with No Return Values
    5. Summary
  7. Using C Functions
    1. Why Use C Functions?
    2. How C Functions Work with RPG IV
    3. Random Numbers from C
    4. C Data Types vs. RPG IV Data Types
    5. Parameter Passing to C Functions
    6. Character String Differences between C and RPG IV
    7. Binding RPG IV and C Functions
    8. Using C Functions to Make Your Job Easier
    9. Summary
  8. Subprocedures
    1. Comparing Subprocedures and Subroutines
    2. Comparing Subprocedures and Static-bound Modules
    3. The Anatomy of a Subprocedure
    4. A Typecheck Subprocedure
    5. A Date-conversion Subprocedure
    6. Subprocedures within a Source Member
    7. Subprocedures outside of a Source Member
    8. Summary
  9. Using Prototyping and ILE to Connect the Functional Parts
    1. Prototyping
    2. The Procedure Interface
    3. Prototype/Procedure Interface Keywords
    4. Binding to Make "Modular" Work Efficiently
    5. The Service Program Signature
    6. The Binding Directory
    7. API Interfacing
    8. Activation Groups
    9. Summary
  10. Coding RPG IV the Modular and Functional Way
    1. Analyze the Program Needs
    2. Gather and/or Code the Needed Subprocedures or Modules
    3. Use Nested BIFs to Eliminate Work Fields
    4. Summary
  11. Free-format RPG IV Coding Standards and Recommendations
    1. Standards
    2. Recommended Coding Practices
    3. Programmer's Choice
  12. Built-in Functions Reference