Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)

Procedure Division
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual426750-001
6-29
COMPUTE Statement
CLEAR requires only a short data sequence; RESET requires a data sequence from
the TCP for each field referred to in the statement.
COMPUTE Statement
The COMPUTE statement evaluates an arithmetic expression and then stores the result
in one or more data items.
result
is the identifier of a numeric elementary item.
expression
is an arithmetic expression calculated according to precedence rules described in
Section 2, SCREEN COBOL Source Program.
As with other arithmetic operations, consider truncation situations and how they should
be handled.
The following example illustrates the COMPUTE statement:
WORKING-STORAGE SECTION.
77 compute-result PIC 999 VALUE ZEROS.
77 ws-result PIC S9(9) VALUE ZEROS.
77 ws-99 PIC S99 VALUE 99.
77 ws-five-ones PIC S9(5) VALUE 11111.
01 exponent PIC 9(5) VALUE ZERO COMP.
:
:
COMPUTE compute-result = (((24.0 + 1) * (60 - 10)) / 125).
(compute-result = 10)
COPY Statement
The COPY statement inserts sections of code into a program for use at compile time.
This allows code that is common to several programs to be written once and be
maintained easily.
copy-text
is a unique section name in a SCREEN COBOL copy library file.
COMPUTE { result } ,... = expression
COPY copy-text [ { OF } library-name ] .
[ { IN } ]