padLeadingWith

padLeadingWith(char: Character;
               max:  Integer): String;

The padLeadingWith method of the Integer primitive type returns a string of the length specified in the max parameter, consisting of the receiving string padded with the leading character specified in the char parameter. If the string is equal to or longer than the value specified in the max parameter, it is not truncated but the whole string is returned.

The following example shows the use of the padLeadingWith method.

constants
    PAD_CHARACTER = 'x';
vars
    int : Integer;
    str : String;
begin
    int := -012345;
    str := int.padLeadingWith('w', 15) & ' 678 Sesame St.';
    write str;     // Outputs wwwwwwwww-12345 678 Sesame St.
    str := int.padLeadingWith('a', 2);
    write str;     // Outputs -12345
    str := int.padLeadingWith(PAD_CHARACTER, 10);
    write str;     // Outputs xxxx-12345
end;