Difference between revisions of "Free Form Calcs"

From MidrangeWiki
Jump to: navigation, search
 
m
Line 1: Line 1:
 +
[[Category:RPG]]
 +
[[Category:Programming]]
 
One of the major new features of RPG 4, introduced in [[V5R1]], is free form calculation specifications.
 
One of the major new features of RPG 4, introduced in [[V5R1]], is free form calculation specifications.
 
=Features=
 
=Features=

Revision as of 16:30, 16 June 2006

One of the major new features of RPG 4, introduced in V5R1, is free form calculation specifications.

Features

  • Removes the column restrictions on calculations.
  • Can be interspersed with standard, fixed form, calcs

Usage

Using free form calculations is quite easy.

  • To start a section of free form calculations, simply put '/free' starting in column 7.
  • On the next line start your free form calculations.
  • Each line must end with a semi-colon ";".
  • Calculations can span multiple lines.
  • End the free form calculation area by putting '/end-free' starting in column 7 on the last line.

Limitations

Example

C                   if        PCFRS = '*ALL'                
C                   eval      #CFRSF = *BLANK               
C                   eval      #CFRSH = *BLANK               
C                   else                                    
C                   eval      #CFRSF = i_CF_Const(PCFRS)    
C                   eval      #CFRSH = #CFRSF               
C                   endif                                   
                                                            
 /free                                                      
  if (pMOLS = '*ALL');                                      
    eval #MOLSF = *blank;                                   
    eval #MOLSH = *blank;                                   
  else;                                                     
    eval #MOLSF = pMOLS;                                    
    eval #MOLSH = pMOLS;                                    
  endif;                                                    
 /end-free                                             
     
C     C#RTNS        IFNE      '*EXITPGM'               
C     C#RTNS        ANDNE     '*RETURN'