System.SysUtils.TStringHelper.PadLeft
Delphi
function PadLeft(TotalWidth: Integer): string; overload; inline;
function PadLeft(TotalWidth: Integer; PaddingChar: Char): string; overload; inline;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.SysUtils.pas | System.SysUtils | TStringHelper |
Description
Right-aligns a string into a fixed-length text space.
var
MyString1: String;
MyString2: String;
begin
MyString1 := '12345';
MyString2 := '123';
Writeln(MyString1.PadLeft(5));
Writeln(MyString2.PadLeft(5));
end.
Output:
12345 123
There are two PadLeft overloaded methods. The first one assumes the pad character is the empty space, while the second one allows you to specify the padding character.