CHARGRAPHIC
CHARGRAPHIC converts a GRAPHIC (DBCS) string x to a mixed character string with a length specified by y.
Abbreviation: CHARG
- x
- Expression.
x must be a GRAPHIC string.
- 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.
y cannot be negative.
CHARGRAPHIC returns a mixed character string that is converted from x.
The following rules apply:
- If y = 0, the result is the null character string.
- If y = 1, the result is a character string of 1 blank.
- If y is greater than the length needed to contain the character string, the result is padded with SBCS blanks.
- If y is less than the length needed to contain the character string, the result is truncated. The integrity is preserved by truncating after a graphic and appending an SBCS blank, if necessary, to complete the length of the string.
Example 1
This example shows a conversion from graphic to character. y is long enough to contain the result.
dcl X graphic(6);
dcl A char (12);
A = char(X,12);
For X with value | Intermediate Result | A is assigned |
---|---|---|
.A.B.C.D.E.F |
.A.B.C.D.E.F |
.A.B.C.D.E.F |
Example 2
This example shows a conversion from graphic to character. However, y is too short to contain the result.
dcl X graphic(6);
dcl A char (12);
A = char(X,11);
For X with value | Intermediate Result | A is assigned |
---|---|---|
.A.B.C.D.E.F |
.A.B.C.D.E.F |
.A.B.C.D.Eb |