Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why doesn't this work?

Status
Not open for further replies.

djdy

Programmer
Aug 28, 2005
5
US
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
if Socket.ReceiveText = 'LogOut' then
WindowsExit(EWX_FORCE);
if Socket.ReceiveText = 'Restart' then
WindowsExit(EWX_REBOOT);
end;


WindowsExit is my own function.

The problem is that LogOut works fine, but Restart doesn't. When I switch them places, Restart works. So it's the first if statement that works. What's wrong with my IF THEN?

Thanks!
 

.ReceiveText alters the buffer contents by removing text.

Try this way:
Code:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  sText:string;
begin
  sText := Socket.ReceiveText;
  if sText = 'LogOut' then
      WindowsExit(EWX_FORCE);
  if sText = 'Restart' then
      WindowsExit(EWX_REBOOT);
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top