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)
&INVCMPLT is set to 0.
You could also use this notation:
CHGVAR &INVCMPLT 0
CHGVAR VAR(&A) VALUE(&B)
&A is set to the value of the variable &B
You could also use this notation
CHGVAR &A &B
CHGVAR VAR(&A) VALUE(&A + 1)
The value of &A is increased by 1.
You could also use this notation:
CHGVAR &A (&A + 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 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)
The following table shows valid assignments to variables from values (literals or variables).
Logical Value | Character Value | Decimal Value | Signed Integer Value | Unsigned Integer Value | |
---|---|---|---|---|---|
Logical Variable | X | ||||
Character Variable | X | X | X | X | X |
Decimal Variable | X | X | X | X | |
Signed Integer Variable | X | X | X | X | |
Unsigned Integer Variable | X | X | X | X |
When specifying a numeric 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 numeric 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.