ILE COBOL Programmer's Guide


Changing the Value of Variables

You can change the value of variables by using the EVAL command with an assignment operator. Unless the variable is on the current line, you must first qualify the variable that you want to change by identifying its line number using the QUAL debug command. Refer to Displaying Variables and Expressions for a description of how to use the QUAL debug command. To change the value of the variable, type:

EVAL variable-name = value

on the debug command line. variable-name is the name of the variable that you want to change and value is an identifier, literal, or constant value that you want to assign to variable variable-name. For example,

EVAL COUNTER=3

changes the value of COUNTER to 3 and shows

COUNTER=3 = 3

on the message line of the Display Module Source display.

You can use the EVAL debug command to assign numeric, alphabetic, alphanumeric, DBCS, boolean, floating-point, and date-time data to variables provided they match the definition of the variable.

Note:
If the value that is assigned to the variable using the EVAL debug command does not match the definition of the variable, a warning message is issued and the value of the variable is not changed.

If the value that is assigned to a variable is a character string, the following rules apply:

The following are examples of how various type of data can be assigned to variables using the EVAL debug command.

EVAL COUNTER=3                    (COUNTER is a numeric variable)
EVAL COUNTER=LIMIT                (LIMIT is another numeric variable)
EVAL END-OF-FILE='1'              (END-OF-FILE is a Boolean variable)
EVAL BOUNDARY=x'C9'               (BOUNDARY is an alphanumeric variable)
EVAL COMPUTER-NAME='ISERIES"      (COMPUTER-NAME is an alphanumeric variable)
EVAL INITIALS=%SUBSTR(NAME 17 3)  (INITIALS and NAME are alphanumeric variables)
EVAL DBCS-NAME= G'OEKIK2K3OF'       (K1K2K3 are DBCS characters)
 
EVAL LONG-FLOAT(3) = -30.0E-3
        (LONG-FLOAT is an array of 3 double-precision floating-point
         data items - COMP-2)
 
EVAL SHORT-FLOAT = 10
        (SHORT-FLOAT is a single-precision floating-point data item -
         COMP-1)
 
Note:
You cannot assign a figurative constant to a variable using the EVAL debug command. Figurative constants are not supported by the EVAL debug command. You may be able to change the value of a constant item in PROCEDURE DIVISION using the EVAL debug command. But the result is unpredictable.


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