CENTERLEFT / CENTRELEFT Function

Purpose

Returns the result of inserting a string in the center or one position to the left of the center of another string with a certain length. It can be padded on the left and on the right with a character.

Syntax

CENTERLEFT(s,l,c)

Parameters

s
A string that is inserted inside another sting. It must have a computational type and a character type. If it does not have a character type, it is converted to character.
l
The length of a string in which s is inserted. It must have a computational type and a character type and is converted to Fixed Binary(31,0).
c
Optional padding character, inserted to the left and to the right of the string. It must have a nonvarying character type.

Examples:

dcl s char (40) var;
    dcl t char (40) var;

    s = 'This string is 33 characters long';
    t = centerleft(s, 40, '+');
    put skip list (t);

will print:

+++This string is 33 characters long++++

Restrictions

None.