| CentreChStr Function | 
Unit
QESBPCSConvert
Declaration
Function CentreChStr(const S: string; const Ch: Char; const Len: LongWord): string;
Description
If even amounts of Ch cannot be put on both side, the extra Ch will be on the right side. Also See: CentreStr
| Parameters | 
| S | the string to be centred. If Length (S) >= Len then NO padding occurs, and S is returned. | 
| Ch | the character to Pad with. | 
| Len | the Length of returned string. | 
Category
Extra String Handling RoutinesImplementation
 
| function CentreChStr (const S: string; const Ch: Char;
     const Len: LongWord): string;
var
     N, M: LongWord;
begin
     N := Length (S);
     if N < Len then
     begin
          M := Len - N; // Length of padding needed
          N := M div 2; // Half on either side
          if Odd (M) then // Handle Odd differently to Even
               Result := FillStr (Ch, N) + S
                    + FillStr (Ch, N + 1)
          else
               Result := FillStr (Ch, N) + S
                    + FillStr (Ch, N);
     end
     else
          Result := S;
End; | 
|  |