From 16f30472a2d042517180e62c3c83255957309e74 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 20 Dec 2017 15:59:53 +0100 Subject: mystringlistunit.pas: tMyStringList.appendTo neu --- mystringlistunit.pas | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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 ihabIchSchon+1 then begin + s:=s+fuge; + bisherLaenge:=bisherLaenge+length(fuge); + end; + end; + end; +end; + // allgemeine Funktionen ******************************************************* procedure _del(var s: string; p,c: longint); -- cgit v1.2.3-70-g09d2