SUBSTR
|
Where
source is a string expression.
starting_position is an integer expression with a value from 1 to 32767.
length is an integer expression with a value from 1 to 32767.
Results
String
Function
The SUBSTR function returns the substring of source that begins at the starting_position and is of length length. If you are simulating a 3270 terminal, you can use the options available on the ATTR3270 function that identify screen location as your starting_position. If length is omitted, the default is the rest of the string.
If the length is greater than the length of the source, then the string is not padded with blanks to length.
Examples
a = substr('ABCDEFG',2,3) /* Assigns 'BCD' to variable "a". */
b = 'ABCDEFG'
a = substr(b,3) /* Assigns 'CDEFG' to variable "a". */
c = 4
a = substr(b,c) /* Assigns 'DEFG' to variable "a". */
d = 2
if substr(b,c,d) = 'DE' then ... /* Condition will be satisfied. */
a = substr(b,4,8) /* Assigns 'DEFG' to variable "a". */