RPG/400 Help

COMP (Compare)

*---------*---------------*-----------------*----------------*---------------*
|   CODE  |    FACTOR 1   |     FACTOR 2    |     RESULT     |  INDICATORS   |
|         |               |                 |      FIELD     |               |
*---------*---------------*-----------------*----------------*---------------*
| COMP    | Comparand     | Comparand       |                |   HI LO EQ    |
|         |               |                 |                |               |
*---------*---------------*-----------------*----------------*---------------*

The COMP operation compares factor 1 with factor 2. Factor 1 and factor 2 can contain a literal, a named constant, a field name, a table name, an array element, a data structure, or a figurative constant. Factor 1 and factor 2 must be either both character or both numeric. As a result of the comparison, indicators are set on as follows:

High: (54-55) Factor 1 is greater than factor 2.
Low: (56-57) Factor 1 is less than factor 2.
Equal: (58-59) Factor 1 equals factor 2.

You must specify at least one resulting indicator in positions 54 through 59. Do not specify the same indicator for all three conditions. When specified, the resulting indicators are set on or off (for each cycle) to reflect the results of the compare.

For further rules for the COMP operation, see Compare Operations.

Figure 23. COMP Operation

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C*  Initial field values are:
C*                    FLDA = 100.00
C*                    FLDB = 105.00
C*                    FLDC = 100.00
C*                    FLDD = ABC
C*                    FLDE = ABCDE
C*
C*  Indicator 12 is set on; indicators 11 and 13 are set off.
C           FLDA      COMP FLDB                 111213
C*
C*  Indicator 15 is set on; indicator 14 is set off.
C           FLDA      COMP FLDB                 141516
C*
C*  Indicator 19 is set on; indicator 17 is set off.
C           FLDA      COMP FLDC                 171819
C*
C*  Indicator 21 is set on; indicators 20 and 22 are set off
C           FLDD      COMP FLDE                 202122

INDICATORS


[ Top of Page | Previous Page | Next Page | Table of Contents ]