Тема: StringList
Показать сообщение отдельно
  #6  
Старый 22.01.2011, 16:16
Аватар для ALexandr555
ALexandr555 ALexandr555 вне форума
Специалист
 
Регистрация: 09.10.2010
Адрес: Тольятти
Сообщения: 803
Версия Delphi: Delphi 7
Репутация: 2064
По умолчанию

Код:
procedure TForm1.ICQClient1MessageRecv(Sender: TObject; Msg, UIN: String);
begin
PK1.add(UIN+'='+Msg);
end;
сдесь добавляется в PK1, PK1 это TStringList

Код:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1potok:=True;
MyThread:= TMyThread.Create;
end;
тут мы таймером устанавливаем что именно мне нужно так как там несколько в потоке IF'ов и создаем поток

Код:
constructor TMyThread.Create;
begin
   Create(True); 
   FreeOnTerminate := True;  после завершения своего кода поток завершится сам
   Priority := tpNormal; 
   Resume; 
end;
создаем поток


Код:
procedure TMyThread.Execute;
var
mem1: integer;
UIN1,Msg1,UIN2,Msg2,UIN3,Msg3,UIN4,Msg4,UIN5,Msg5,UIN6,Msg6,UIN7,Msg7,UIN8,Msg8,UIN9,Msg9,UIN10,Msg10: string;
potokkomand1,potokkomand2,potokkomand3,potokkomand4,potokkomand5,potokkomand6,potokkomand7,potokkomand8,potokkomand9,potokkomand10: TstringList;
begin
potokkomand1:=TstringList.Create;
potokkomand2:=TstringList.Create;
potokkomand3:=TstringList.Create;
potokkomand4:=TstringList.Create;
potokkomand5:=TstringList.Create;
potokkomand6:=TstringList.Create;
potokkomand7:=TstringList.Create;
potokkomand8:=TstringList.Create;
potokkomand9:=TstringList.Create;
potokkomand10:=TstringList.Create;
potokkomand1:=PK1;
potokkomand2:=PK2;
potokkomand3:=PK3;
potokkomand4:=PK4;
potokkomand5:=PK5;
potokkomand6:=PK6;
potokkomand7:=PK7;
potokkomand8:=PK8;
potokkomand9:=PK9;
potokkomand10:=PK10;
PK1.Clear;
PK2.Clear;
PK3.Clear;
PK4.Clear;
PK5.Clear;
PK6.Clear;
PK7.Clear;
PK8.Clear;
PK9.Clear;
PK10.Clear;
If Timer1potok = True then
begin
 Timer1potok:=false;
 if potokkomand1.Count-1 > 6 then
  begin
   for mem1:=potokkomand1.Count-1 Downto 0 do
    begin
     UIN1:=copy(potokkomand1.strings[mem1],1,pos('=',potokkomand1.strings[mem1])-1);
     Msg1:=copy(potokkomand1.strings[mem1],pos('=',potokkomand1.strings[mem1])+1,length(potokkomand1.strings[mem1]));
     potokkomand1.Delete(mem1);
     Form1.obrabotchik1(UIN1, Msg1);
     sleep(200);
    end;
  end
else
 begin
  for mem1:=potokkomand1.Count-1 DownTo 0 do
   begin
    UIN1:=copy(potokkomand1.strings[mem1],1,pos('=',potokkomand1.strings[mem1])-1);
    Msg1:=copy(potokkomand1.strings[mem1],pos('=',potokkomand1.strings[mem1])+1,length(potokkomand1.strings[mem1]));
    potokkomand1.Delete(mem1);
    Form1.obrabotchik1(UIN1, Msg1);
  end;
 end;
end;
код потока основной P.S. там еще идет 10 аналогичных If Timer1potok = True then с последующими действиями функций но они тоже не работают
Ответить с цитированием