• Aucun résultat trouvé

COMMON PHRASES AND GENERAL RULES FOR STATEMENT FORMATS In the statement descriptions that

Dans le document TRAX COBOL Language Reference Manual (Page 138-142)

PROCEDURE DIVISION

5.7 COMMON PHRASES AND GENERAL RULES FOR STATEMENT FORMATS In the statement descriptions that

frequently: the ROUNDED phrase, CORRESPONDING phrase.

follow, several the SIZE ERROR

phrases appear phrase, and the In the discussion below, a resultant-identifier is that identifier associated with a result of an arithmetic operation.

5.7.1 The ROUNDED Phrase

If, after decimal point alignment, the number of places in the fraction of the result of an arithmetic operation is greater than the number of places provided for the fraction of the resultant-identifier, truncation is relative to the size provided for the resultant-identifier. When rounding is requested, the absolute value of the resultant-identifier is increased by 1 whenever the most significant digit of the excess is greater than or equal to 5.

When the low-order integer positions in a resultant-identifier are represented by the character P in the PICTURE clause for that resultant-identifier, rounding or truncation occurs relative to the rightmost integer position for which storage is allocated.

5.7.2 The SIZE ERROR Phrase

If, after decimal point alignment, the absolute value of a result exceeds the largest value that can be contained in the associated resultant-identifier, a size error condition exists. Division by ·0 always causes a size error condition. The size error condition condition occurs, the value of those resultant-identifier(s) affected is undefined. Values of resultant-identifier(s) for which no size error condition occurs are unaffected by size errors that occur for other resultant-identifier(s) during execution of this operation.

2. If the SIZE ERROR phrase is specified and a size error condition occurs, then the value of the resultant-identifier(s) affected by the size errors is not altered. Values of resultant-identifier(s) for which no size error condition occurs are unaffected by size errors that occur for other resultant-identifier(s) during execution of

PROCEDURE DIVISION

this operation. After completion of the execution of this operation, the imperative statement in the SIZE ERROR phrase is executed.

For the ADD statement with the CORRESPONDING phrase and the SUBTRACT statement with the CORRESPONDING phrase, if any of the individual operations produces a ~size error condition, the imperative statement in the SIZE ERROR phrase is not executed until all of the individual additions or subtractions are completed.

5.7.3 The CORRESPONDING Phrase

For the purpose of this discussion, dl and d2 must each be identifiers that refer to group items. A pair of data items, one from d 1 and one from d2 correspond if the following conditions exist:

1. A data item in d and a data item in d are not designated by the key word FILLER and have the same data-name and the same qualifiers up to, but not including, d and d .

2. In the case of a MOVE statement with the CORRESPONDING phrase, at least one of the data items is an elementary data item; in the case of the ADD statement with the CORRESPONDING phrase or the SUBTRACT statement with the CORRESPONDING phrase, both of the data items are elementary numeric data items.

3. The description of dl and d2 must not contain level-number 66, 77, or 88 or the USAGE IS INDEX clause.

4. A data item that is subordinate to dl or d2 and contains a REDEFINES, RENAMES, OCCURS, or USAGE IS INDEX clause is

ignored, as well as those data items subordinate to the data item that contains the REDEFINES, OCCURS, or USAGE IS INDEX clause. However, dl and d2 may have REDEFINES or OCCURS clauses or be subordinate to data items with REDEFINES or OCCURS clauses. (See Section 4.19, The OCCURS Clause.)

5.7.4 The Arithmetic Statements

The arithmetic statements are the ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT statements. They have several common features.

1. The data descriptions of the operands need not be the same;

any necessary conversion and decimal point alignment is supplied throughout the calculation.

5-27

2. The maximum size of each operand is IS decimal digits. The composite of operands, which is a hypothetical data item resulting from the superimposition of specified operands in a statement aligned on their decimal points, must not contain more than IS decimal digits.

5.7.5 Multiple Results in Arithmetic Statements

The ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT statements may have multiple results. Such statements behave as though they had been written in the following way:

1. A statement that performs all arithmetic necessary to arrive at the result to be stored in the receiving items, and stores that result in a temporary storage location.

2. A sequence of statements transferring or combining the value of this temporary location with a single result. These statements are considered to be written in the same left-to-right sequence in which the multiple results are listed.

The result of the statement

ADD a, b, c TO c; d (c), e is equivalent to

ADD a, b, c GIVING temp ADD temp TO c

ADD temp TO d (c) ADD temp TO e

where temp is an intermediate result item defined as follows:

The number of integer places in temp is the maximum of the integer places of all the operands in the statement. The number of decimal places is the maximum of all the operands in the statement. If the sum of the number of integer places and decimal places is greater than IS, then the number of integer places will be reduced until the sum is equal to IS.

Therefoxe, high-order truncation could occur in some receIvIng operands, depending on the resulting value of the arithmetic statement.1

PROCEDURE DIVISION 5.7.6 Overlapping Operands

When a sending and a receiving item in an arithmetic statement or INSPECT, MOVE, SET, STRING, or UNSTRING statement share a part of their storage areas, the result of the execution of such a statement is undefined. The compiler does not detect overlapping or potentially overlapping operands.

5.7.7 Incompatible Data

Except for the class condition (see Section 5.6.6, Class Condition), when the contents of a data item are referenced in the Procedure Division and the contents of that data item are not compatible with the class specified for that data item by its PICTURE clause, then the result of such a reference is undefined.

5-29

ACCEPT

5.8 THE ACCEPT STATEMENT

Dans le document TRAX COBOL Language Reference Manual (Page 138-142)