How to: |
If your configuration uses a DBCS code page, you can use the DSUBSTR function to extract a substring based on its length and position in the source string.
DSUBSTR(inlength, source_string, start, end, sublength, output)
where:
Integer
Is the length of the source string in bytes. The string can have a mixture of DBCS and SBCS characters. Therefore, the number of bytes represents the maximum number of characters possible in the source string.
Alphanumeric
Is the string from which the substring will be extracted .
Integer
Is the starting position (in number of characters) of the substring in the source string. If this argument is less than one or greater than end, the function returns spaces.
Integer
Is the ending position (in number of characters) of the substring. If this argument is less than start or greater than inlength, the function returns spaces.
Integer
Is the length of the substring, in characters (normally end - start + 1). If sublength is longer than end - start +1, the substring is padded with trailing spaces. If it is shorter, the substring is truncated. This value should be the declared length of output. Only sublength characters will be processed.
Alphanumeric
The following example extracts the 3-character substring in positions 4 through 6 from a 15-byte string of characters:
iWay Software |