diff options
-rw-r--r-- | mystringlistunit.pas | 29 |
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); |