To:
GoodWind _List:=TStringlist.Create;
выдаёт ошибку ! её надо немного модернизировать под сортировку только хз как !
Код
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Memo3: TMemo;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1; i:integer; _List:TStrings;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,num:integer; _List,_ListCount:TStrings; tmpBuf:string;
function GetNumLine(_List:TStrings; FileString:string):integer;
var i:integer;
begin
result:=-1;
for i:=0 to _list.Count-1 do
if pos(FileString+'|',_list.Strings[i])>0 then begin
result:=i;
exit;
end;
end;
begin
_List:=TStringlist.Create;
_ListCount:=TStringlist.Create;
try
_List.LoadFromFile('c:\s.txt');
if fileexists('c:\_count.txt') then _ListCount.LoadFromFile('c:\_count.txt');
memo2.Clear;
for i:=0 to memo1.Lines.Count-1 do begin
if _List.IndexOf(memo1.Lines.Strings[i])<>-1 then
memo2.Lines.Add(memo1.Lines.Strings[i]);
num:=GetNumLine(_ListCount,memo1.Lines.Strings[i]);
if num<0 then _ListCount.Add(memo1.Lines.Strings[i]+'|1') else begin
tmpBuf:=_ListCount.Strings[num];
_ListCount.Strings[num]:=memo1.Lines.Strings[i]+'|'+
inttostr(strtoint(copy(tmpBuf,pos('|',tmpBuf)+1,
length(tmpBuf)-pos('|',tmpBuf)))+1);
end;
end;
if memo2.Lines.Count=0 then memo2.Lines.Add('Ieoeaa ia iaeaaii...');
memo3.Clear;
for i:=0 to _ListCount.Count-1 do
memo3.Lines.Add(copy(_ListCount.Strings[i],1,pos('|',_ListCount.Strings[i])-1) +
' - ' + copy(_ListCount.Strings[i],pos('|',_ListCount.Strings[i])+1,
length(_ListCount.Strings[i])-pos('|',_ListCount.Strings[i])));
_ListCount.SaveToFile('c:\_count.txt');
finally
_List.Free;
_ListCount.free;
end;
end;
_List:=TStringlist.Create;
try
_List.LoadFromFile('c:/s.txt');
memo2.Clear;
for i:=0 to memo1.Lines.Count-1 do
if _List.IndexOf(memo1.Lines.Strings[i])<>-1 then
memo2.Lines.Add(memo1.Lines.Strings[i]);
if memo2.lines.count<0 then memo2.Lines.Add('Ничего не найдено...');
finally
_List.Free;
end.