Autor Beitrag
tc4xe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Sa 01.07.06 00:36 
Sitze schon fast ne Stunde und suche meinen Fehler....

s := IdTCPClient1.IOHandler.ReadLn;

Nach dem Compilieren gibt Delphi 7 (Indy 10) mir diesen Fehler:
Undefinierter Bezeichner: 'Readln'

Bitte helft mir, hier nochmal mein sourcecode:



ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, IdBaseComponent, IdComponent, IdTCPServer,
  IdTCPConnection, IdTCPClient;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    IdTCPClient1: TIdTCPClient;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
IdTCPClient1.Host := '127.0.0.0.1';
IdTCPClient1.Port := 750;
IdTCPClient1.Connect;
end;

procedure TForm1.FormCreate(Sender: TObject);
var s: String;
begin
s := IdTCPClient1.IOHandler.ReadLn;

if AnsiSameText(s, 'Hallo?'then
IdTCPClient1.IOHandler.WriteLn('Servus!');
end;

end.
PLuS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 98

Win XP, Suse Linux 9.0
D5 Standard, D2005 Personal; Perl; PureBasic
BeitragVerfasst: Sa 01.07.06 02:24 
ReadLine ist eine Funktion vom Socket, nicht vom IOHandler.

Demnach:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  S: string;
begin
  S := IdTCPClient1.Socket.ReadLn;
  //...
end;


Ich denke, dass du die beiden Events auch vertauschst, oder warum versucht dein Programm schon beim Start vom Socket zu lesen und verbindet sich im Intervall des Timers immer wieder neu???

Also so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Timer1Timer(Sender: TObject); 
var
  s: String
begin 
  s := IdTCPClient1.IOHandler.ReadLn; 
  if AnsiSameText(s, 'Hallo?'then 
    IdTCPClient1.IOHandler.WriteLn('Servus!');  
end


procedure TForm1.FormCreate(Sender: TObject); 
begin
  IdTCPClient1.Host := '127.0.0.0.1'
  IdTCPClient1.Port := 750
  IdTCPClient1.Connect; 
end;

_________________
Der letzte macht die Tür zu!
tc4xe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Sa 01.07.06 11:23 
Guck dir mal den Post von ulrix an:

www.delphi-forum.de/...p;highlight=sendtext

Das mit dem Timer habe ich einfach so gemacht, man soll sich eigentlich mit einem Button verbinden.

MfG