Examples: Change character variable

This example changes the value of a character variable using the EVAL debug command.

CL declarations:   DCL    VAR(&CHAR1) TYPE(*CHAR) LEN(1) VALUE
('A')
                   DCL    VAR(&CHAR2) TYPE(*CHAR) LEN(10)
 
 
Debug command:     EVAL &CHAR1 = 'B'
 
Result:            &CHAR1 = 'B' = 'B'
 
 
Debug command:     EVAL &CHAR1 = X'F0F1F2F3'
 
Result:            &CHAR1 = 'F0F1F2F3' = '0'
 
 
Debug command:     EVAL &CHAR2 = 'ABC'
 
Result:            &CHAR2 = 'ABC' = 'ABC       '
 
 
Debug command:     EVAL %SUBSTR(CHAR2 1 2) = %SUBSTR(&CHAR2 3 1)
 
Result:            %SUBSTR(CHAR2 1 2) = %SUBSTR(&CHAR2 3 1) = 'C '
 
Comment:           Variable &CHAR contains 'C C       '

The %SUBSTR built-in function allows you to substring a character string variable. The first argument must be a string identifier, the second argument is the starting position, and the third argument is the number of single byte or double byte characters. Arguments are delimited by one or more spaces.