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.
.....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C FieldA COMP 'A' 21 C EXFMT DspError
.....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C IF FieldA = 'A' C SETON 21 C EndIf C EXFMT DspError
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.