COMPARE OPERATION


As previously mentioned, the COMP operation is normally not often used in the modern RPG language. It is, however, often overlooked when communicating with an externally described workstation or printer file. When an indicator is needed to communicate with an external file, the COMP operation is used to test the condition and set on a resulting indicator. The resulting indicator can be used by the externally described file to issue an error message, change the color of a field, or cause additional fields to be written to the display or printer. See Figure 7.15 and 7.16.

start figure

 .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq      C     FieldA        COMP      'A'                                21      C                   EXFMT     DspError 

end figure

Figure 7.15: COMP operation used to communicate with a DEVICE file.

start figure

 .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq      C                   IF        FieldA = 'A'      C                   SETON                                        21      C                   EndIf      C                   EXFMT     DspError 

end figure

Figure 7.16: IF and SETON used to communicate with a DEVICE file.

Figure 7.15 shows the simpler technique. The COMP operation compares factor 1 to factor 2 and sets on the appropriate resulting indicators. Figure 7.16 illustrates an alternate and less-used technique.




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