MPSTR Function

Purpose

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.

Syntax

MPSTR(x,r[,y])

Parameters

x, y, and r are expressions.

Description

x yields the character string result. The value of x is converted to character if necessary.

r yields a character result. The expression cannot be GRAPHIC and is converted to character if necessary. 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, results are undefined.

y, if necessary, 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.

Restrictions

r is ignored on Intel and AIX.