COBOL/400 Language Help


COMPUTE Statement

Description
The COMPUTE statement assigns the value of an arithmetic expression to one or more data items. It allows you to combine arithmetic operations without the restrictions on receiving data items that the rules for the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements impose. When you need to combine arithmetic operations, using the COMPUTE statement may be more efficient than writing a series of separate arithmetic statements.
             *------------------------*
             V                        +
->->---COMPUTE identifier-1--*----------*--------------------->
                           *-ROUNDED--*
 
->---- =  arithmetic-expression------------------------------>
 
 
->---*--------------------------------------------*---------->
    *-*----*--SIZE ERROR imperative-statement-1--*
      *-ON-*
 
->---*-------------------------------------------------*----->
    *--NOT-*----*--SIZE ERROR imperative-statement-2--*
           *-ON-*
 
->---*---------------*---------------------------------------><-
    *--END-COMPUTE--*
 


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