Previous Topic: Arithmetic CommandsNext Topic: COMPUTE


ADD

Purpose

Calculates the sum of two values.

Syntax

►►─── ADD arithmetic-expression to variable ─── options ── . ────────────►◄

Expansion of options

►───┬─────────────────────────────────┬──────────────────────────────────────►◄
    ├─ ROUNDED ───────────────────────┤
    ├─ TRUNCATED ─────────────────────┤
    └─ ALLOWING assignment-condition ─┘

Parameters

arithmetic-expression

Specifies the value being added to the value in variable.

to variable

Specifies the field that contains the value to which arithmetic-expression is added. Following execution of the command, variable contains the result of the ADD operation.

ROUNDED

Rounds the result of the addition to the number of decimal positions found in variable.

TRUNCATED

Truncates the result of the addition to the number of decimal positions found in variable.

The default specification is ROUNDED if COBOL moves are enabled is not selected and TRUNCATED if the option is selected.

More information:

For more information, see 13.4, "Assignment Command" later in this chapter.

ALLOWING

Specifies which error conditions would normally abend and should cause control to be returned to the dialog for error handling. The list of allowable assignment-condition names can be found in the section entitled "Arithmetic and Assignment Command Status Condition."

Usage

The ADD command is used to perform addition. A variable data field value, a numeric literal, or the result of an arithmetic expression is added to a data field value. The result is placed in the data field that contains the right operand.

Example

The following example uses the ADD command to add the value 1 to the contents of the variable data field COUNTER.

ADD 1 TO COUNTER.

More information:

Arithmetic Expressions