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
COMPUTE
command to assign a value to a program variable only if you first enter theSET WARNING OFF
command. - 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.
COMPUTE
assigns a value only to a single receiver; unlike COBOL, multiple receiver variables are not supported.- The COBOL
EQUAL
keyword is not supported ("=" must be used). - The COBOL
ROUNDED
andSIZE ERROR
phrases are not supported, soEND-COMPUTE
is not supported. COMPUTE
cannot 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
COMPUTE
will be treated as aMOVE
and therefore subject to the same rules as theMOVE
command. - If the
DATA
parameter of thePLAYBACK ENABLE
command is in effect for the current compile unit, theCOMPUTE
command can be used while you replay recorded statements by using thePLAYBACK
commands. The target of theCOMPUTE
command 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
x
the value ofa
+ 6.COMPUTE x = a + 6;
- Assign to the variable
mycode
the value of the z/OS Debugger variable%PATHCODE + 1
.COMPUTE mycode = %PATHCODE + 1;
- Assign to variable
xx
the 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)