COMPUTE command (COBOL)
The COMPUTE command assigns the value of an arithmetic
expression to a specified reference. The COMPUTE keyword
cannot be abbreviated.
- reference
- A valid z/OS® Debugger COBOL numeric reference.
- expression
- A valid z/OS Debugger COBOL numeric expression.
Usage notes
- If you are debugging an optimized COBOL program, you can use the
COMPUTEcommand to assign a value to a program variable only if you first enter theSET WARNING OFFcommand. - If you are debugging an optimized COBOL program and you specify an expression, you can reference program variables that were not discarded by the optimizer.
- If z/OS Debugger was started because of a computational condition or an attention interrupt, using an assignment to set a variable might not give expected results. This is due to the uncertainty of variable values within statements as opposed to their values at statement boundaries.
COMPUTEassigns a value only to a single receiver; unlike COBOL, multiple receiver variables are not supported.- The COBOL
EQUALkeyword is not supported ("=" must be used). - The COBOL
ROUNDEDandSIZE ERRORphrases are not supported, soEND-COMPUTEis not supported. COMPUTEcannot be used to perform a computation with a windowed date field if the expression consists of more than one operand.- Any expanded date field specified as an operand in the expression is treated as a nondate field.
- The result of the evaluation of the expression is always considered to be a nondate field.
- If the expression consists of a single
numeric operand, the
COMPUTEwill be treated as aMOVEand therefore subject to the same rules as theMOVEcommand. - If the
DATAparameter of thePLAYBACK ENABLEcommand is in effect for the current compile unit, theCOMPUTEcommand can be used while you replay recorded statements by using thePLAYBACKcommands. The target of theCOMPUTEcommand must be a session variable. - The value assigned to a variable is always assigned to the storage for that variable. In an optimized program, a variable can be temporarily assigned to a register, and a new value assigned to that variable does not necessarily alter the value used by the program.
Examples
- Assign to variable
xthe value ofa+ 6.COMPUTE x = a + 6; - Assign to the variable
mycodethe value of the z/OS Debugger variable%PATHCODE + 1.COMPUTE mycode = %PATHCODE + 1; - Assign to variable
xxthe result of the expression(a + e(1)) / c * 2.COMPUTE xx = (a + e(1)) / c * 2;You can also use table elements in such assignments as shown in the following example.COMPUTE itm-2(1,2) = (a + 10) / e(2);
Refer to the following topics for more information related to the material discussed in this topic.
- Related references
- MOVE command (COBOL)
- PLAYBACK commands
- SET WARNING command (C, C++, COBOL, and PL/I)
