[Delphi] Ошибка[DCC Error] Unit1.pas(35): E2029 'END' expected but 'IMPLEMENTATION'

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by tracy, 21 Jun 2010.

  1. tracy

    tracy Elder - Старейшина

    Joined:
    24 Mar 2009
    Messages:
    244
    Likes Received:
    119
    Reputations:
    40
    Ошибочка

    Code:
    Checking project dependencies...
    Compiling Project1.dproj (Debug configuration)
    [DCC Hint] Unit1.pas(29): H2365 Override method TNewTheard.execute should match case of ancestor TThread.Execute
    [DCC Error] Unit1.pas(35): E2029 'END' expected but 'IMPLEMENTATION' found
    [DCC Error] Unit1.pas(53): E2003 Undeclared identifier: 'PageProfile'
    [DCC Error] Unit1.pas(53): E2003 Undeclared identifier: 'edit1'
    [DCC Error] Unit1.pas(53): E2010 Incompatible types: 'string' and 'Text'
    [DCC Error] Unit1.pas(53): E2029 '(' expected but '+' found
    [DCC Error] Unit1.pas(56): E2029 Declaration expected but 'IF' found
    [DCC Error] Unit1.pas(61): E2029 '.' expected but ';' found
    [DCC Warning] Unit1.pas(62): W1011 Text after final 'END.' - ignored by compiler
    [DCC Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
    Failed
    Elapsed time: 00:00:00.5
    Исходник

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
      StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        IdHTTP1: TIdHTTP;
        Edit1: TEdit;
        Edit2: TEdit;
        Label1: TLabel;
        Label2: TLabel;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
      TNewTheard = class (TThread)
      private
      protected
       procedure execute; override;
       public
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
    PageProfile:string;
    begin
      TNewTheard.Create(false);
    end;
    procedure TNewTheard.Execute ;
    
    begin
    
     Form1.IdHTTP1.AllowCookies:=true;
     Form1.IdHTTP1.HandleRedirects:=true;
     try
    
      PageProfile:=Form1.IdHTTP1.Get('http://russianproxy.ru/proxy_checker?proxy='+edit1.Text+'&proxy_port='+edit2.Text+'');
     except
     end;
     if Pos('Response time', PageProfile)<>0 then
     Form1. Memo1.Lines.Add('Прокси сервер: '+edit1.Text+':'+edit2.Text+' Рабочий ')
    
     else
      Form1.Memo1.Lines.Add('Bad');
      Form1.Memo1.Lines.Clear ;
    end;
    
    
    
    end.
     
  2. FairHawk

    FairHawk Member

    Joined:
    16 Mar 2010
    Messages:
    46
    Likes Received:
    6
    Reputations:
    0
    сделай поток в отдельном листинге
    new - TThread
    Потом в uses добавь
     
    #2 FairHawk, 21 Jun 2010
    Last edited: 21 Jun 2010
  3. tracy

    tracy Elder - Старейшина

    Joined:
    24 Mar 2009
    Messages:
    244
    Likes Received:
    119
    Reputations:
    40
    Приведи пример с кодом )
     
  4. fenixelite

    fenixelite Banned

    Joined:
    7 Feb 2010
    Messages:
    294
    Likes Received:
    56
    Reputations:
    6
    После public забыл end;
     
  5. HakaR

    HakaR Active Member

    Joined:
    23 Jul 2009
    Messages:
    301
    Likes Received:
    200
    Reputations:
    3
    Вроде нельзя юзать в потоках компоненты с форм, т.е. создавай в потоке idhttp.
    PageProfile обьявляй в самом потоке.
    Form1.edit1
     
    2 people like this.
  6. tracy

    tracy Elder - Старейшина

    Joined:
    24 Mar 2009
    Messages:
    244
    Likes Received:
    119
    Reputations:
    40
    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
      StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        IdHTTP1: TIdHTTP;
        Edit1: TEdit;
        Edit2: TEdit;
        Label1: TLabel;
        Label2: TLabel;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
      TNewTheard = class (TThread)
      private
      protected
       procedure execute; override;
       public
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
    PageProfile:string ;
    begin
      TNewTheard.Create(false);
    end;
    procedure TNewTheard.Execute  ;
    
    begin
    
     Form1.IdHTTP1.AllowCookies:=true;
     Form1.IdHTTP1.HandleRedirects:=true;
     try
    
      PageProfile:=Form1.IdHTTP1.Get('http://russianproxy.ru/proxy_checker?proxy='+Form1.edit1.Text+'&proxy_port='+Form1.edit2.Text+'');
     except
     end;
     if Pos('Response time', PageProfile)<>0 then
     Form1. Memo1.Lines.Add('Прокси сервер: '+Form1.edit1.Text+':'+Form1.edit2.Text+' Рабочий ')
    
     else
      Form1.Memo1.Lines.Add('Bad');
      Form1.Memo1.Lines.Clear ;
    end;
    
    
    
    end.
    Code:
    Checking project dependencies...
    Compiling Project1.dproj (Debug configuration)
    [DCC Hint] Unit1.pas(29): H2365 Override method TNewTheard.execute should match case of ancestor TThread.Execute
    [DCC Hint] Unit1.pas(42): H2164 Variable 'PageProfile' is declared but never used in 'TForm1.Button1Click'
    [DCC Error] Unit1.pas(54): E2003 Undeclared identifier: 'PageProfile'
    [DCC Error] Unit1.pas(57): E2250 There is no overloaded version of 'Pos' that can be called with these arguments
    [DCC Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
    Failed
    Elapsed time: 00:00:00.4
     
  7. FairHawk

    FairHawk Member

    Joined:
    16 Mar 2010
    Messages:
    46
    Likes Received:
    6
    Reputations:
    0
    New - Other - TThread
    Главный код проги:
    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
      IdHTTP, StdCtrls, unit2;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        IdHTTP1: TIdHTTP;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      NEW  : Load; // имя твоего потока
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Load.Create(false); // или как тебе там надо
    end;
    
    end.
    
    Код потока:
    Code:
    unit Unit2;
    
    interface
    
    uses
      Classes;
    
    type
      Load = class(TThread)
      private
        { Private declarations }
      protected
        procedure Execute; override;
      end;
    
    implementation
    
    uses
      unit1;
    
    procedure Load.Execute;
    begin
      Form1.IdHTTP1.AllowCookies:= true;
      //
    end;
    
    end.
    
     
  8. Refqs

    Refqs Banned

    Joined:
    20 Feb 2010
    Messages:
    139
    Likes Received:
    56
    Reputations:
    27
    Полностью проект http://slil.ru/29369032
     
  9. HakaR

    HakaR Active Member

    Joined:
    23 Jul 2009
    Messages:
    301
    Likes Received:
    200
    Reputations:
    3
    PHP:
    procedure TNewTheard.Execute;
    var
      
    httptidhttp;
      
    pagestring;
    begin
      http 
    := tidhttp.Create(nil);
      
    http.AllowCookies:=true;
      
    http.HandleRedirects:=true;

      try
       
    Page := http.Get('http://russianproxy.ru/proxy_checker?proxy='
                        
    form1.edit1.Text '&proxy_port=' form1.edit2.Text);
      
    except
      end
    ;

      if 
    Pos('Response time'Page) <> 0 then
      Form1
    .Memo1.Lines.Add('Прокси сервер: ' form1.edit1.Text
                             
    ':' form1.edit2.Text 'рабочий ')
      else
      
    Form1.Memo1.Lines.Add('Bad');
    end;
    PHP:
    procedure TForm1.Button1Click(SenderTObject);
    begin
      TNewTheard
    .Create(False);
    end;
    Вроде работает...
     
  10. FairHawk

    FairHawk Member

    Joined:
    16 Mar 2010
    Messages:
    46
    Likes Received:
    6
    Reputations:
    0
    tracy тебе и так тут помогли, куда еще?)
    Просить вставить свой код , в чужой шаблон (ПМ), это уже сверх наглости и лени, сам
     
  11. Refqs

    Refqs Banned

    Joined:
    20 Feb 2010
    Messages:
    139
    Likes Received:
    56
    Reputations:
    27


    А Resume ГДЕ?
    Я дал самый стабильный и рабочий код в предыдущем посте.
     
  12. tracy

    tracy Elder - Старейшина

    Joined:
    24 Mar 2009
    Messages:
    244
    Likes Received:
    119
    Reputations:
    40
    HakaR , спасибо ;)
     
  13. HakaR

    HakaR Active Member

    Joined:
    23 Jul 2009
    Messages:
    301
    Likes Received:
    200
    Reputations:
    3
    Create(False) - что бы поток сам запустился, сразу после создания.
    Можно еще и FreeOnTerminate, ну у тебя же этого нету.
    Ок.
     
  14. Refqs

    Refqs Banned

    Joined:
    20 Feb 2010
    Messages:
    139
    Likes Received:
    56
    Reputations:
    27
    да.. точно