Science Fair Projects Ideas - RPG programming language

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

RPG programming language

(Redirected from RPG (programming language))

RPG or RPG IV is a native programming language for IBM's iSeries (aka AS400) minicomputer system. In its latest incarnation includes prototyped functions and procedures, static and dynamic binding, access to C routine libraries, dynamic link libraries, and fully recursive and re-entrant code.

Overview

An RPG program typically starts off with a File Specification, listing all files being written to, read from or updated, followed by an Input Specification containing program elements such as Data Structures and dimensional arrays. This is followed by the Calculation Specification which contains the actual meat of the code, and finally the Output Specifications which can be used to determine the layout of the report.

The major strength of RPG is known as "The Cycle": every RPG program executes within an implied loop, which can apply the program to every record of a file. Alternately, "The Cycle" can make an interactive program continue to run until explicitly stopped.

The other distinguishing characteristic of RPG is that it, to a far greater extent than COBOL or FORTRAN, is column-dependent.

History

RPG, is one of the few languages created for punch card machines that is still in common use today. It was originally developed by IBM in the 1960s and ran on the popular IBM 1401. Originally, RPG was an acronym for Report program generator, descriptive of the purpose of the language: generation of reports from data files, including matching record and sub-total reports.

The alternative languages generally available at the time were either COBOL or BASIC, one verbose, the other a poor tool for development, so RPG became pre-eminent on IBM hardware.

RPG was further developed by IBM for their range of mainframe systems, especially the S/390 - as RPG II.

Because the language syntax was based on the plugboards used to program unit record equipment, and the System 3 was initially developed as a successor to plugboard-programmable unit record machines, RPG II was ported to the System 3, System 32, System 34, and System 36, while an improved version of the language, RPG III, was created for the System 38 and its successor the AS/400 (a mid-range machine, now evolved into the E-Server iSeries) and became RPG/400 with a much cleaner syntax, and better file/database reading capabilities. This language was the mainstay of development on the AS/400, and its editor was a simple line editor with prompt templates for each specification (type of instruction).

RPG III significantly departed from the original language, providing modern structured constructs like IF-ENDIF blocks, DO loops, and subroutines.

In 1998 RPG IV (aka RPG/LE aka RPG/ILE) was released and the name, officially, was no longer an acronym. RPG IV offered a free-format text-capable source entry, as an alternative to the orignal column-dependent source format, and a greater variety of expressions within its new Extended Calculation Specification.

RPG has thrived on the object-oriented API of the OS/400 operating system to such an extent that everything is a file (somewhat similar to the Unix philosophy): the terminal screen can be updated (with sub windows) by simply writing to a file (of type *DISPLAY).

Example code

The following program receives a customer number as an input parameter and returns the name and address as output parameters.


      * Historically RPG is columnar in nature, though free-formatting
      * is allowed under particular circumstances.  
      * The purpose of various lines code are determined by a 
      * letter code in column 6.
      * An asterisk (*) in column 7 denotes a comment line

      * "F" (file) specs define files and other i/o devices
     FARMstF1   UF   E             Disk    Rename(ARMST:RARMST)

      * "D" specs are used to define variables
     D pCusNo          S              6p 0
     D pName           S             30a
     D pAddr1          S             30a
     D pAddr2          S             30a
     D pCity           S             25a
     D pState          S              2a
     D pZip            S             10a

      * "C" (calculation) specs are used for executable statements
      * Parameters are defined using plist and parm opcodes 
     C     *entry        plist
     C                   parm                    pCusNo
     C                   parm                    pName
     C                   parm                    pAddr1
     C                   parm                    pAddr2
     C                   parm                    pCity
     C                   parm                    pState
     C                   parm                    pZip

      * The "chain" command is used for random access of a keyed file
     C     pCusNo        chain     ARMstF1

      * If a record is found, move fields from the file into parameters
     C                   if        %found
     C                   eval      pName  = ARNm01
     C                   eval      pAddr1 = ARAd01
     C                   eval      pAddr2 = ARAd02
     C                   eval      pCity  = ARCy01
     C                   eval      pState = ARSt01
     C                   eval      pZip   = ARZp15
     C                   endif
       
      * RPG makes use of switches.  One switch "LR" stands for 
      * "last record".  This ends program execution.
     C                   eval      *InLR = *On
 


10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice