On Nov 21, 2007, at 3:06 PM, Damien Gerard wrote:
As I could not find a function into the RTL to do that, here is a
function to cut too long strings. The advantage is to have the right
part of the string in the same time. It is usefull to me to display
long paths. I don't know if it will be usefull to you but I share
it, just in case.
Sorry I copy/paste the old one...
function CutString(const s: UTF8String; const maxLen: integer = 30;
const rightSide: boolean = false; const rightSideLen: integer = 8) :
UTF8String;
var i : integer;
begin
if (0 = maxLen) or (length(s) < maxLen) or (rightSideLen > maxLen
- 4) then
begin
result := s;
exit;
end;
if rightSide then
begin
i := maxLen - (rightSideLen + 3);
result := TrimRight(leftStr(s, i)) + '...' +
TrimLeft(rightStr(s, rightSideLen));
end else begin
result := leftStr(s, maxLen - 3) + '...';
end;
end;
--
Damien Gerard
[EMAIL PROTECTED]
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives