SUBSTR pseudovariable

The SUBSTR pseudovariable assigns a string value to a substring, specified by y and z, of x. The remainder of x is unchanged. Assignments to a varying string do not change the length of the string.

Read syntax diagramSkip visual syntax diagramSUBSTR( x, y, z)
x
String-reference. x must not be a numeric character.
y
Expression. y expression that can be converted to a FIXED BINARY value which specifies the starting position of the substring in x.
z
Expression. z specifies the length of the substring in x. It can be converted to a real fixed-point binary value. If z is zero, a null string is returned. If z is omitted, the substring returned is position y in x to the end of x.

y and z can be arrays only if x is an array.

When the STRINGRANGE condition is disabled, an assignment to SUBSTR(x,1,z) assigns a string of length z to the address specified by ADDRDATA(x). If z > MAXLENGTH(x), the program is invalid and data past the end of x will be overwritten. For example, if x is CHAR(10) and z has the value 15, then 10 blanks will be written to x and 5 blanks will be written over the storage after x.