Autor Beitrag
arcitC|Crash
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 88


D4 weiter weiß ich net
BeitragVerfasst: Do 04.08.05 01:05 
Ich weiß ehrlich gesagt nicht, wie ich das Problem eigentlich beschriebn soll, aber hier mal der Quellcode:

ausblenden 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:
procedure TForm1.ServerClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
  var RecText : string;
      leng : integer;
      header : string;
      txt : string;
      com : string;
begin
  recText := socket.ReceiveText;
  leng := length(RecText);
  header := copy(RecText, 1, 3);
    If header = 'txt' Then
       begin
         txt := copy(RecText, 5, leng);
         Showmessage(txt);
       end;
    End;



    If header = ('com') Then
       com := copy(RecText, 5, leng);
    End;


Für mich sieht alles in Ordnung aus, aber beim Compilen kommt immer der Fehler
[Hinweis] server.pas(45): Variable 'com' wurde deklariert aber in 'TForm1.ServerClientRead' nicht verwendet
[Fehler] server.pas(59): Deklaration erwartet, aber 'IF' gefunden

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: Do 04.08.05 01:54 
Ein end zuviel, ein begin zuwenig ...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.ServerClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
  var RecText : string;
      leng : integer;
      header : string;
      txt : string;
      com : string;
begin
  recText := socket.ReceiveText;
  leng := length(RecText);
  header := copy(RecText, 1, 3);
  If header = 'txt' then
   begin
    txt := copy(RecText, 5, leng);
    Showmessage(txt);
   end;

  If header = ('com') then
   com := copy(RecText, 5, leng);
end;


Bedenke, dass man nur durch begin, aber nicht durch then einen Block einleitet, der dann mit end geschlossen werden muss.

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Do 04.08.05 06:46 
Hallo!

Du hast nicht richtig eingerückt, daher fiel das dir auch nicht auf. Eine auf "then" oder "do" folgende "begin"-Anweisung wird nicht nach rechts gerückt (der Inhalt des "begin/end"-Blockes natürlich schon).

Cu,
udontknow
arcitC|Crash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 88


D4 weiter weiß ich net
BeitragVerfasst: Do 04.08.05 12:38 
Ah jo, alles klar, es funktioniert jetzt, danke!
arcitC|Crash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 88


D4 weiter weiß ich net
BeitragVerfasst: Do 04.08.05 13:05 
Toll, jetzt ein weiteres Problem:

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:
procedure TForm1.ServerClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
  var RecText : string;
      leng : integer;
      header : string;
      txt : string;
      com : string;
begin
  recText := socket.ReceiveText;
  leng := length(RecText);
  header := copy(RecText, 1, 3);
  If header = 'txt' Then
  begin
    txt := copy(RecText, 5, leng);
    Showmessage(txt);
  end;

  If header = 'com' Then
     com := copy(RecText, 5, leng);



  If com = '$123ShutdownServer123$' Then
  begin
    Server.active := false;
    Form1.Close;
  end;
  If com = '$123Shutdown123$' Then
     ExitWindowsEx (EWX_SHUTDOWN, $FFFFFFFF);
  If com = '$123UnhiderServer123$' Then
     Form1.visible := true;   
end;


Wenn der Client einen Text verschickt, der angezeigt werden soll beim Server, passiert das auch.
Sobald ich aber einen Befehl mit "com" versende, der zum ausführen von Befehlen ist, passiert absolut nichts.

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
arcitC|Crash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 88


D4 weiter weiß ich net
BeitragVerfasst: Do 04.08.05 18:18 
Alles klar hat sich erledigt^^
Ich habe beim Clienten immer einen Rechtschreibfehler gehabt, weshalb der Text auch nie erkannt wurde :D
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Do 04.08.05 20:23 
Um so etwas zu vermeiden, solltest du die Konstanten als solche in einer separaten Unit definieren, die sowohl Client als auch Server einbinden.

Cu,
Udontknow