diff options
Diffstat (limited to 'mystringlistunit.pas')
-rw-r--r-- | mystringlistunit.pas | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mystringlistunit.pas b/mystringlistunit.pas index d37be08..a98e452 100644 --- a/mystringlistunit.pas +++ b/mystringlistunit.pas @@ -28,6 +28,7 @@ type procedure grep(expr: string; invert: boolean = false); function grepFirst(expr: string): string; procedure replace(von,nach: string); + procedure uniq(c: char); procedure append(sl: tMyStringList); overload; function hatZeile(zeile: string): boolean; // invers zu "grep -c" function eof: boolean; @@ -228,6 +229,33 @@ begin self[i]:=re.replace(self[i],nach,true); end; +procedure tMyStringlist.uniq(c: char); +var + i: longint; + dup: boolean; +begin + case c of + '-': // only keep one line for each group + for i:=count-1 downto 1 do + if self[i]=self[i-1] then + delete(i); + 'd': begin // only keep duplicate lines, one for each group + dup:=false; + for i:=count-1 downto 0 do begin + if (i>0) and (self[i]=self[i-1]) then begin + dup:=true; + delete(i); + continue; + end; + if not dup then + delete(i); + dup:=false; + end; + end; + else fehler('Unbekannte Option '''+c+''' für tMyStringList.uniq!'); + end{of case}; +end; + procedure tMyStringlist.append(sl: tMyStringList); var i: longint; |