Command reference / CL
CHGVAR
Change Variable
Changes the value of a CL variable, or part of a character variable. The new value can be a constant, another variable, or the result of an expression or built-in function. Decimal and character values convert implicitly under the rules given in the VALUE description. The %BINARY/%BIN, %SUBSTRING/%SST and %SWITCH built-in functions can be used in VAR or VALUE.
Allowed environments: *BPGM, *IPGM.
Use within a CL program.
Positional parameters: 2.
Restrictions
- Valid only in a CL program or ILE CL procedure.
Parameters
VAR
CL variable name
Specifies the CL variable whose value is to be changed. Its type need not match the VALUE type unless an expression is evaluated or VAR is a logical variable. For substring or binary built-in functions, give the character variable followed by the start position and length.
VALUE
New value
Specifies the expression used to change the variable's value. Variables, constants, or a built-in function can be used within the expression.
*NULL- Sets a CL pointer variable to a null value. Valid when compiled with CRTCLMOD or CRTBNDCL. With CRTCLPGM, set the pointer from a pointer declared with ADDRESS(*NULL) that has not been changed.
Examples
CHGVAR &A &B
Sets &A to the value of &B. If &B is 37.2, then &A becomes 37.2 also.
CHGVAR &Y (&Y + 1)
Increases the value of &Y by 1. If &Y is 216, its value becomes 217.
CHGVAR VAR(&A) VALUE(AB *CAT CD)
Sets &A to the concatenation of AB and CD, ABCD. Shown in keyword form with unquoted strings.
Generated from os/cl/catalog/CHGVAR.json and os/cl/help/CHGVAR.json.