Funcao - string padding |
Top Previous Next |
// Pad Right with char
function PadR(const AStr : string; ALength : integer; AFillChar : char = ' ') : string; var sResult : string; begin sResult := trim(AStr);
if ALength <= length(sResult) then sResult := copy(sResult,1,ALength) else sResult := sResult + StringOfChar(AFillChar,ALength - length(sResult));
Result := sResult; end;
// Pad Left with char{ Right justify a string
function PadL(const AStr : string; ALength : integer; AFillChar : char = ' ') : string; var sResult : string; begin sResult := trim(AStr);
if ALength <= length(sResult) then sResult := copy(sResult,1,ALength) else sResult := StringOfChar(AFillChar,ALength - length(sResult)) + sResult;
Result := sResult; end; |