Chapter 12: Alternate Syntax Options


The RPG IV language accepts operation codes on its calculation specifications, but there are actually three distinct syntax structures for calculation specifications. The first structure is the traditional fixed-format syntax that has been a part of RPG since it was first introduced. Fixed format syntax is still supported in RPG IV. The second format is the enhanced or alternate calculation specification that supports what is called the Extended factor 2. The extended factor 2 allows natural expressions to be performed. The first structure is free-format syntax. In Free-format syntax only natural expressions are supported and the entry of the natural expressions is permitted from position 8 through 80 of the source line.

FIXED-FORMAT CALCULATION SPECIFICATIONS

Traditional fixed-format calculations are the most widely used form of statement. This is due primarily to the legacy of RPG and its original fixed-format only coding. Today, RPG IV programmers primarily use a combination of the traditional fixed-format specifications along with the enhanced specifications.

Figure 12.1 contains an example of using the traditional fixed-format calculation specifications.

start figure

 .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq 0001 C     CustNo        Chain     CustRec                            71 0002 C     *IN71         ifeq      *OFF 0003 C                   Add       1             Visits 0004 C                   Update    CustRec 0005 C                   endif 

end figure

Figure 12.1: Traditional fixed-format calculations.

In Figure 12.1, line 1 illustrates the CHAIN operation code, which is the common file access method used in RPG programs. Line 2 uses the deprecated IFEQ operation code to check for a record found condition. If the CHAIN operation is successful, *IN71 will be equal to *OFF, otherwise if the record is not found *IN71 will be equal to *ON. Line 3 increments the field named VISITS which is a field in the customer master file. And finally, on Line 4, the customer master file record CUSTREC is updated; all the fields of the file are rewritten to the database.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net