Board index » delphi » Delphi searching first characters of string

Delphi searching first characters of string

I was wondering if there is any way to know what the first 4
characters are in a string. What I am creating is a text-based network
game and text is sent between the server/client. If the client
receives text that says User they'll respond with user*** where *** is
the username. I want to know if they've sent text starting with user.
Here's my code.

procedure TfrmAdminGemstone.ssockServerClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
var
  ClientUser: string;
  ClientPass: string;
  Connecting: boolean;
  ReceivedText: string;
  i: integer;
begin
  Connecting := False;
  ReceivedText := Socket.ReceiveText;
  if ReceivedText = 'user*' then begin
    ClientUser := ReceivedText;
    Connecting := True;
    Socket.SendText('Received');
  end;
end;

When I use an asterisk it doesn't use it as a wildcard, I want to know
if there is a wildcard character as such or another way to do it. Any
help is appreciated.

Best Regards,
     Staunch, hae...@optushome.com.au

 

Re:Delphi searching first characters of string


Quote
"Staunch" <hae...@optushome.com.au> wrote in message
>   if ReceivedText = 'user*' then begin

    if ANSICompareText (Copy (ReceivedText, 1, 4), 'user') = 0
    then . . .

Re:Delphi searching first characters of string


thank you for your help

Other Threads