Strings Delphi

Title: A Simple Way to Center String for a Specified Length
Question: How to centered a string for specified length (like in a header/title of a table's column in a plain text report)
Eg : we want to create like this :
----------------------------------------------------------
| Column1 | Column2 |
----------------------------------------------------------
Answer:
Basicly, I tried to use the built in Delphi function here
to do such job, n its works,
you can do that by using this simply code :
--------------------------------------------
function CenterString(aStr: String; Len: Integer): String;
var
posStr : integer;
begin
if Length(aStr)Len then
Result := Copy(aStr, 1, Len)
else
begin
posStr := (len - Length(aStr)) div 2;
Result := Format('%*s', [len, aStr + Format('%-*s', [posStr, ''])]);
end;
end;
procedure Trial_MakeHeader;
var titleColumn1, titleColumn2, titleLine2 : String;
begin
// ... prior code lines
titleColumn1 := CenterString('Column1', 15);
titleColumn2 := CenterString('Column2', 29);
titleLine2 := Format('|%s|%s|', [titleColumn1, titleColumn2]);
// ... next code lines
end;
Try it.