Registriert seit: 19. Dez 2005
Ort: Rosdorf
2.022 Beiträge
Turbo Delphi für Win32
|
Re: Totales Brett vorm Kopf: Problem mit 'end'
12. Feb 2006, 19:57
Erstmal danke für die mühe, hier ist die komplette procedure, ääääh Pro>z<edur
Delphi-Quellcode:
procedure TfrmMain.IdTCPServerExecute(AThread: TIdPeerThread);
var
Command, Answer : String; i, j : Integer; OK: Boolean;
begin
if Edit1.Text<>'' then
begin
AThread.Connection.WriteLn(Edit1.Text);
Exit;
end;
Answer:='';
Command := AThread.Connection.ReadLn;
lbProcesses.Items.Insert(0, 'Getting Command: '+Command);
Command := uppercase(Command);
if Command = 'TIME' then begin
AThread.Connection.WriteLn(FormatDateTime('hh:nn:ss',now));
lbProcesses.Items.Insert(0, 'Sending Command: '+FormatDateTime('hh:nn:ss',now)); end
else if Command = 'DATE' then begin
AThread.Connection.WriteLn(FormatDateTime('dd/mmm/yyyy',date));
lbProcesses.Items.Insert(0, 'Sending Command: '+FormatDateTime('dd/mmm/yyyy',date)); end
else if Command = 'TICKCOUNT' then begin
j:=GetTickCount;
AThread.Connection.WriteLn(IntToStr(j));
lbProcesses.Items.Insert(0, 'Sending Command: '+IntToStr(GetTickCount)); end
else if Command = 'QUIT' then
begin
AThread.Connection.WriteLn('Cya!');
lbProcesses.Items.Insert(0, 'Sending Command: Cya!');
AThread.Connection.Disconnect;
end
else if Command = 'GETLIST' then
begin
for i := 0 to ListBox1.Count-1 do Answer:=Answer+('; '+ListBox1.Items[i]);
AThread.Connection.WriteLn(Answer);
lbProcesses.Items.Insert(0, 'Sending Command: '+Answer)
end
else if Command = 'SHUTDOWN' then
begin
AThread.Connection.WriteLn('Shutdown Server');
lbProcesses.Items.Insert(0, 'Shutdown Server');
AThread.Connection.Disconnect;
btnExit.Click;
end
else if Command = 'RESTART' then
begin
AThread.Connection.WriteLn('Restarting Server in 3 seconds...');
lbProcesses.Items.Insert(0, 'Restarting Server in 3 seconds...');
Timer1.Enabled:=true;
end
else if (Command[1]+Command[2]+Command[3]+Command[4]+Command[5]) = 'LOGIN' then
begin
OK:=true;
for i := 0 to ListBox1.Count-1 do if Uppercase(ListBox1.Items[i])=Copy(Command, 6, Length(Command)) then OK:=false;
if ok then
begin
if (Copy(Command, 6, Length(Command)) = 'HAMSTER') or (Copy(Command, 6, Length(Command)) = 'IGEL') then
begin
ListBox1.Items.Add(Copy(Command, 6, Length(Command)));
AThread.Connection.WriteLn('VER:0.1');
lbProcesses.Items.Insert(0, 'Sending Command: loginok');
end;
end;
end
else
begin
AThread.Connection.WriteLn('loginnotok');
end
else if Command[1]+Command[2]+Command[3]+Command[4]+Command[5]+Command[6] = 'LOGOUT' then
begin
for i := 0 to ListBox1.Count-1 do
begin
if Uppercase(ListBox1.Items[i])=Copy(Command, 7, Length(Command)) then
begin
ListBox1.Items.Delete(i);
lbProcesses.Items.Insert(0, ('Logged out '+Copy(Command, 7, Length(Command))));
end;
end;
AThread.Connection.WriteLn('logoutok');
end
else
begin
AThread.Connection.WriteLn('Ungültiger Befehl!');
lbProcesses.Items.Insert(0, 'Sending Command: Ungültiger Befehl!');
end;
end;
Nikolai Wyderka
SWIM SWIM HUNGRY!
Neuer Blog: hier!
|
|
Zitat
|