MPSTR truncates a string at a logical boundary and returns a mixed
character string. It does not truncate a double-byte character between
bytes. The length of the returned string is equal to the length of
the expression
x, or to the value specified by
y.
The processing of the string is determined by the rules selected by
the expression
r, as described below.
>>-MPSTR(x,r-+----+-)------------------------------------------><
'-,y-'
- x
- Expression that yields the character string result. The value
of x is converted to character if necessary.
- r
- Expression that yields a character result. The expression cannot
be GRAPHIC and is converted to character if necessary.
The expression r specifies
the rules to be used for processing the string. The characters that
can be used in r and the rules for them are as follows:
- V or v
- Validates the mixed string x and returns a mixed string.
- S or s
- Removes any null DBCS strings, creates a new string, and returns
a mixed string.
If both V and S are specified, V takes precedence over
S, regardless of the order in which they were specified.
If
S is specified without V, the string x is assumed to be a valid string.
If the string is not valid, undefined results occur.
Note: The parameter r is ignored on Intel and AIX.
- y
- Expression. If necessary, y is converted to a real
fixed-point binary value. If y is omitted, the length is
determined by the rules for type conversion. The value of y cannot
be negative. If y = 0, the result is the null character string.
If y is greater than the length needed to contain x,
the result is padded with blanks. If y is less than the length
needed to contain x, the result is truncated by discarding
excess characters from the right (if they are SBCS characters), or
by discarding as many DBCS characters (2-byte pairs) as needed.