Previous Topic: DECODE CommandNext Topic: DEFINE Command


DECREMENT Command

(Area 3)

The DECREMENT command algebraically decrements the contents of a predefined numeric field by a specified numeric value or the contents of another predefined numeric field. DECR or REDUCE can be used in place of DECREMENT.

The format of the DECREMENT commands follows:

►►─┬────────────────┬─┬─ DECR ──────┬─ fieldname1 ─┬──────┬───────────────────►
   └─ label: ───────┘ ├─ DECREMENT ─┤              └─ BY ─┘
                      └─ REDUCE ────┘

 ►─┬─ fieldname2 ───────┬─┬───────────────────────────┬─┬─────────┬───────────►◄
   └─ numeric constant ─┘ └─┬──────────┬─ fieldname3 ─┘ └─ ROUND ─┘
                            └─ GIVING ─┘
label:

Specifies an optional identifying label that allows a GOTO branch to be made to this statement.

fieldname1

Specifies the name given a predefined numeric field whose value represents the minuend for the subtraction of two variables. Predefine the field name as zoned decimal, packed decimal, binary, or unsigned binary.

fieldname2

Specifies the name given a predefined numeric field whose value is to be used as the subtrahend for the subtraction of two variables. Predefine the field name as zoned decimal, packed decimal, binary, or unsigned binary..

numeric constant

Specifies an absolute numeric constant to be used as the subtrahend in the calculation. It can be any valid numeric literal.

fieldname3

Optionally specifies a predefined numeric field in which the difference is placed. Predefine the field name as zoned decimal, packed decimal, binary, or unsigned binary.

ROUND

Optionally defines whether the result will be rounded before being placed into the result field. For rounding to occur, the computed value must have more decimal places than the result field. The default is not to round.

Example

           Predefined field name:     FIELD1     FIELD2     FIELD3     INDEX
		  Numeric precision:       3.2        1.4        3.4       2.0
          Initial value of field:    (123.45)   (5.4321)      (1)       (10)
    DECREMENT INDEX BY 1                  nc         nc         nc         9
    DECREMENT INDEX BY FIELD3             nc         nc         nc         9
    DECREMENT FIELD1 BY FIELD2
         GIVING FIELD3                    nc         nc   118.0179        nc
    DECR FIELD1 BY -1.5               124.95         nc         nc        nc
    DECREMENT INDEX BY FIELD2
         GIVING FIELD3                    nc         nc     4.5679        nc
    REDUCE INDEX BY INDEX                 nc         nc         nc         0
    REDUCE FIELD3 BY 10                   nc         nc    -9.0000        nc
    DECREMENT FIELD3 INDEX INDEX          nc         nc         nc        -9
    DECREMENT FIELD2 BY FIELD3            nc     4.4321         nc        nc
    DECREMENT INDEX BY 2.93               nc         nc         nc         7
    DECR FIELD1 BY +.92               122.53         nc         nc        nc
    REDUCE FIELD2 BY .333                 nc     5.0991         nc        nc

Note the following: