You can change the value of a CL variable using the Change Variable (CHGVAR) command. The value can be changed:
CHGVAR VAR(&INVCMPLT) VALUE(0)
or
CHGVAR &INVCMPLT 0
&INVCMPLT is set to 0.
CHGVAR VAR(&A) VALUE(&B)
or
CHGVAR &A &B
&A is set to the value of the variable &B
CHGVAR VAR(&A) VALUE(&A + 1)
or
CHGVAR &A (&A + 1)
The value of &A is increased by 1.
CHGVAR VAR(&A) VALUE(%SST(&B 1 5))
&A is set to the first five characters of the value of the variable &B
CHGVAR VAR(&A) VALUE(%SWITCH(0XX111X0))
&A is set to 1 if job switches 1 and 8 are 0 and job switches 4, 5 and 6 are 1; otherwise, &A is set to 0.
CHGVAR VAR(&A) VALUE(%BIN((%B 1 4))
The first four characters of variable &B are converted to the decimal equivalent and stored in decimal variable &A
The CHGVAR command can be used to retrieve and to change the local data area also. For example, the following commands blank out 10 bytes of the local data area and retrieve part of the local data area:
CHGVAR %SST(*LDA 1 10) ' ' CHGVAR &A %SST(*LDA 1 10)
For a logical variable, the value to which the variable is to be changed must be a logical value. For decimal variables, a decimal or character value can be used. For character variables, either character or decimal values are accepted.
When specifying a decimal value for a character variable, remember the following:
For example, &A is a character variable to be changed to the value of the decimal variable &B The length of &A is 6. The length and decimal positions of &B are 5 and 2, respectively. The current value of &B is 123. The resulting value of &A is 123.00.
When specifying a character value for a decimal variable, remember the following:
For example, &C is a decimal variable to be changed to the value of the character variable &D The length of &C is 5 with 2 decimal positions. The length of &D is 10 and its current value is +123.1bbbb (where b=blank). The resulting value of &C is 123.10.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.