The COMPUTE statement assigns the value of an arithmetic expression to one or more data items.
With the COMPUTE statement, arithmetic operations can be combined without the restrictions on receiving data items imposed by the rules for the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements.
When arithmetic operations are combined, the COMPUTE statement can be more efficient than the separate arithmetic statements written in a series.
___ Format _____________________________________________________________ | | | <___________________________ | | >>__COMPUTE____identifier-1__ _________ _|__ _=_______ ______________> | | |_ROUNDED_| |_ EQUAL _| | | | | >__arithmetic-expression_____________________________________________> | | | | >__ ____________________________________________ ____________________> | | |_ ____ __SIZE ERROR__imperative-statement-1_| | | |_ON_| | | | | >__ _________________________________________________ _______________> | | |_NOT__ ____ __SIZE ERROR__imperative-statement-2_| | | |_ON_| | | | | >__ _____________ __________________________________________________>< | | |_END-COMPUTE_| | | | |________________________________________________________________________|
When the COMPUTE statement is executed, the value of the arithmetic expression is calculated, and this value is stored as the new value of each data item referenced by identifier-1.
An arithmetic expression consisting of a single identifier, numeric function, or literal allows the user to set the value of the data item(s) referenced by identifier-1 equal to the value of that identifier or literal.
Subtopics:
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.