CHARACTER

CHARACTER returns the character value of x, with a length specified by y. CHARACTER also supports conversion from graphic to character type.

Read syntax diagramSkip visual syntax diagram
>>-CHARACTER(x-+----+-)----------------------------------------><
               '-,y-'     

Abbreviation: CHAR

x
Expression.

x must have a computational type.

When x is nongraphic, CHARACTER returns x converted to character.

When x is GRAPHIC, CHARACTER returns x converted to SBCS characters. If a DBCS character cannot be translated to an SBCS equivalent, the CONVERSION condition is raised.

The values of x are not checked.

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.

If y = 0, the result is the null character string.

Example: Conversion from graphic to character

  dcl X graphic(6);
  dcl A char (6);
  A = char(X);

For X with value

Intermediate result

A is assigned

.A.B.C.D.E.F

ABCDEF

ABCDEF






Published: 23 December 2018