summaryrefslogtreecommitdiff
path: root/mystringlistunit.pas
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-12-20 15:59:53 +0100
committerErich Eckner <git@eckner.net>2017-12-20 15:59:53 +0100
commit16f30472a2d042517180e62c3c83255957309e74 (patch)
tree86c2ba26b5206f1bb6709954841db145d8f1a20b /mystringlistunit.pas
parentaeac304b61b00cf576e1d5caf164a7526df904df (diff)
downloadunits-16f30472a2d042517180e62c3c83255957309e74.tar.xz
mystringlistunit.pas: tMyStringList.appendTo neu
Diffstat (limited to 'mystringlistunit.pas')
-rw-r--r--mystringlistunit.pas29
1 files changed, 29 insertions, 0 deletions
diff --git a/mystringlistunit.pas b/mystringlistunit.pas
index 7698e26..1a5e9ba 100644
--- a/mystringlistunit.pas
+++ b/mystringlistunit.pas
@@ -44,6 +44,7 @@ type
procedure nichtInSubRoutine(s: string);
procedure addWithLineBreaks(s: string);
function last: string;
+ procedure appendTo(wen: tStringList; maxLen: int64; praeludium,fuge,coda: string);
end;
procedure _del(var s: string; p,c: longint); inline; // identisch zu delete(s,p,c) -- lediglich um delete innerhalb von tMyStringList verfügbar zu haben
@@ -656,6 +657,34 @@ begin
result:=self[count-1];
end;
+procedure tMyStringList.appendTo(wen: tStringList; maxLen: int64; praeludium,fuge,coda: string);
+var
+ habIchSchon,bisherLaenge,i,j: longint;
+ s: string;
+begin
+ if count=0 then
+ exit;
+ habIchSchon:=-1;
+ bisherLaenge:=length(praeludium)+length(coda);
+ s:=praeludium;
+ for i:=0 to count do begin
+ if (i=count) or (bisherLaenge+length(self[i])+byte(i>habIchSchon+1)*length(fuge) > maxLen) then begin
+ wen.append(s+coda);
+ habIchSchon:=i;
+ bisherLaenge:=length(praeludium)+length(coda);
+ s:=praeludium;
+ end;
+ if i<count then begin
+ bisherLaenge:=bisherLaenge+length(self[i]);
+ s:=s+self[i];
+ if i>habIchSchon+1 then begin
+ s:=s+fuge;
+ bisherLaenge:=bisherLaenge+length(fuge);
+ end;
+ end;
+ end;
+end;
+
// allgemeine Funktionen *******************************************************
procedure _del(var s: string; p,c: longint);