CL Command Reference - CHGPGMVAR

CL Command List > CHGPGMVAR Reference

Description:

The Change Program Variable (CHGPGMVAR) command changes the value of a variable in a program being debugged. Only string (character or bit) and numeric variables can be changed using this command. A portion of a character string or bit string can be changed; the length of the data to be changed is the length of the data specified on the New value (VALUE) parameter.

Note: Depending on where the variable is allocated, the duration of a change varies. For a variable in machine-interface (MI) static storage, the change lasts while the program is active. For an automatic variable, the change lasts until the call of the program is ended. Static variables are allocated either in MI static storage or in spaces controlled by language-dependent rules.

Restrictions:

. You can use this command only in debug mode. To start debug mode, refer to the Start Debug (STRDBG) command.

. You cannot use this command if you are servicing another job, and that job is on a job queue, or is being held, suspended, or ended.

. You cannot use this command to change variables in a bound program.

. You cannot use this command to change variables that are write-protected or within the system domain, unless the user has service (*SERVICE) special authority.


Examples:

Example 1: Changing the Program Variable

DCL VAR(&AMT) TYPE(*DEC) LEN(5 2)
:
CHGPGMVAR PGMVAR(¡¯&AMT¡¯) VALUE(16.2)

The first command, which is used in a CL program, declares the CL variable &AMT as a five-position decimal value having a 3-digit integer and a 2-digit fraction. The Change Program Variable (CHGPGMVAR) command is used to change the value of &AMT to 16.20. If VALUE is coded as 16 or 16.00, the value accepted is 16.00; if -16 is coded, the value accepted is -16.00. However, if 1600 is coded, an error occurs because the system assumes that, if no decimal point is coded, it is always on the right of the last digit coded.



Example 2: Changing a Value in a Specific Position

CHGPGMVAR PGMVAR(PARTNO) VALUE(¡¯56¡¯) START(4)

This command changes, starting in position 4, the program variable PARTNO to ¡¯56¡¯.