ok i have a problem with my code when i try to compile i get the following errors [ EXCEPT OR FINALLY expected ] and [ ';' expected but ',' found ]
can anyone help?
[code]
procedure TForm1.RunCommand(ss: string; rSocket: TCustomWinSocket);
var
nnn, n, n2, j, i: integer;
black, found: boolean;
sss, s1, s2, s3, s4, s5, s: string;
com: string;
tag, l, nSpace: Integer;
NewData, sCommand, sData: String;
b: Boolean;
label
TheSkipper;
begin
sss := ss;
try
if (length(sss) > 3) then
sss := DecodeStr(sss)
else
exit;
nnn := 0;
while (DecodeCommand(sss, scommand, sdata)) and (nnn < 1000) do
begin
nnn := nnn + 1;
s := '';
tag := Finder(rSocket.SocketHandle);
// WE'VE GOT DATA!!!
ChatUsers[tag].m_SockData := ChatUsers[tag].m_SockData + rSocket.ReceiveText();
l := InStr(1, ChatUsers[tag].m_SockData, CrLf);
while l <> 0 do
begin
NewData := mid(ChatUsers[tag].m_SockData, 1, l - 1);
ChatUsers[tag].m_SockData := mid(ChatUsers[tag].m_SockData, l + 2);
l := InStr(1, ChatUsers[tag].m_SockData, CrLf);
if ShowRawData.Checked then
AddText('> ' + rSocket.RemoteAddress + ':Data' + CrLf + NewData);
nSpace := InStr(1, NewData, ' ');
if nSpace <> 0 then
begin
sCommand := mid(NewData, 1, nSpace - 1);
sData := mid(NewData, nSpace + 1);
end
else
begin
sCommand := NewData;
sData := '';
end;
s:=''; s2:=''; s3:='';
n:=0; n2:=0;
b:=False;
ChatUsers[tag].m_LastMsg := Time;
ChatUsers[tag].m_ScrollCount := ChatUsers[tag].m_ScrollCount + 1;
if (ChatUsers[tag].m_ScrollCount > 3) and (sCommand <> 'line') then
begin
rSocket.Close();
RemoveUser(ChatUsers[tag]);
Exit;
end;
// we don't want any commands but 'nick' from people w/o a nick
if (ChatUsers[tag].m_Nick = '') and (sCommand <> 'nick') then
Exit;
// Changes your nickname
if sCommand = 'nick' then // in: nick newnick
begin // out: newnick newnick, nick oldnick:newnick
if sData = '' then
goto TheSkipper;
n := InStr(1, sData, ':');
if n = 0 then
begin
s := sData;
s2 := RemoveInvals(_l(sData));
end
else
begin
s := mid(sData, 1, n-1);
s2 := RemoveInvals(_l(s));
s3 := trim(mid(sData, n+1));
end;
for n := Low(ChatUsers) to High(ChatUsers) do
if ChatUsers[n].m_InUse then
if _l(ChatUsers[n].m_Nick) = s2 then
begin
rSocket.SendText('error Nickname in use' + CrLf);
goto TheSkipper;
end;
if ChatUsers[tag].m_Nick = sData then
begin
rSocket.SendText('error This is your nick already' + CrLf);
goto TheSkipper;
end;
if (s2 <> _l(s)) or (s = '') then
begin
rSocket.SendText('error Nickname invalid' + CrLf);
goto TheSkipper;
end;
if length(s) > 15 then
begin
rSocket.SendText('error Nickname exceeds 15 bytes' + CrLf);
goto TheSkipper;
end;
ChatUsers[tag].m_Mode := 0;
// check if its a reserved nickname
for n := 0 to lstUsers.Items.Count - 1 do
if s2 = RemoveInvals(_l(lstUsers.Items.Item[n].SubItems.Strings[0])) then
if s3 <> lstUsers.Items.Item[n].SubItems.Strings[1] then
begin
rSocket.SendText('error Nickname is reserved' + CrLf);
goto TheSkipper;
end
else
begin
ChatUsers[tag].m_Mode := StrToInt(lstUsers.Items.Item[n].Caption);
end;
// notify people of the change
for n := Low(ChatUsers[tag].m_Chats) to High(ChatUsers[tag].m_Chats) do
if ChatUsers[tag].m_Chats[n] <> '' then
SpreadChat(ChatUsers[tag].m_Chats[n],
'nick ' + ChatUsers[tag].m_Chats[n] + ':' + ChatUsers[tag].m_Nick + ':' + _m(ChatUsers[tag]) + s + CrLf);
if ShowMovement.Checked then
AddText('> ' + rSocket.RemoteAddress + ':Changed nick from ' + ChatUsers[tag].m_Nick + ' to ' + s);
ChatUsers[tag].m_Nick := s;
rSocket.SendText('newnick ' + s + CrLf);
end // Sends a message
else if sCommand = 'msg' then // in: msg chat:message
begin // out: msg chat:sayer:message
// check if they are afk
if ChatUsers[tag].m_Idle = True then
begin
ChatUsers[tag].m_Idle := False;
ModeChange(ChatUsers[tag]);
end;
n := InStr(1, sData, ':');
if n = 0 then
goto TheSkipper;
s := mid(sData, 1, n-1);
s2 := trim(mid(sData, n+1));
if s = '' then
goto TheSkipper;
if s2 = '' then
goto TheSkipper;
if length(s2) > 250 then
s2 := mid(s2, 1, 250);
if s2 = '' then
goto TheSkipper;
for n := low(chatusers[tag].m_Chats) to high(chatusers[tag].m_Chats) do
if chatusers[tag].m_Chats[n] = s then
begin
SpreadChat(s, 'msg ' + s + ':' + ChatUsers[tag].m_Nick + ':' + s2 + CrLf);
if ShowMessages.Checked then
AddText('> ' + rSocket.RemoteAddress + ':In ' + s + ', ' + ChatUsers[tag].m_Nick + ' says ' + s2);
goto TheSkipper;
end;
rSocket.SendText('error You are not in this chatroom' + CrLf);
end
else if sCommand = 'me' then // in: me chat:message
begin // out: me chat:sayer:message
// check if they are afk
if ChatUsers[tag].m_Idle = True then
begin
ChatUsers[tag].m_Idle := False;
ModeChange(ChatUsers[tag]);
end;
n := InStr(1, sData, ':');
if n = 0 then
goto TheSkipper;
s := mid(sData, 1, n-1);
s2 := trim(mid(sData, n+1));
if s = '' then
goto TheSkipper;
if s2 = '' then
goto TheSkipper;
if length(s2) > 250 then
s2 := mid(s2, 1, 250);
if s2 = '' then
goto TheSkipper;
SpreadChat(s, 'me ' + s + ':' + ChatUsers[tag].m_Nick + ':' + s2 + CrLf);
if ShowMessages.Checked then
AddText('> ' + rSocket.RemoteAddress + ':In ' + s + ', ' + ChatUsers[tag].m_Nick + ' ' + s2);
end // Joins a chatroom
else if sCommand = 'join' then // in: join room
begin // out: came room:person
// mem room:persons
// check for invalid'ness // joined room
if sData = '' then
goto TheSkipper;
if length(sData) > 25 then
begin
rSocket.SendText('error Room name too long' + CrLf);
goto TheSkipper;
end;
if RemoveInvals(trim(sData)) <> sData then
begin
rSocket.SendText('error Room name invalid' + CrLf);
goto TheSkipper;
end;
s := _l(sData);
for n := Low(ChatUsers[tag].m_Chats) to High(ChatUsers[tag].m_Chats) do
if s = _l(ChatUsers[tag].m_Chats[n]) then
begin
rSocket.SendText('error Your allready in this room' + CrLf);
goto TheSkipper;
end;
if high(ChatUsers[tag].m_Chats) >= 4 then
begin
rSocket.SendText('error Your in too many rooms' + CrLf);
goto TheSkipper;
end;
// Find out who's in this chat and what the proper casing/spacing is
for n := low(ChatUsers) to high(ChatUsers) do
for n2 := low(ChatUsers[n].m_Chats) to high(ChatUsers[n].m_Chats) do
if s = _l(ChatUsers[n].m_Chats[n2]) then
sData := ChatUsers[n].m_Chats[n2];
// This will add numbers to chats
n2 := 0;
s := sData;
while True do
begin
inc(n2);
if CountRoom(s) < 30 then
Break
else
s := sData + ' ' + IntToStr(n2);
end;
sData := s;
// notify current chatters of this arrival
SpreadChat(sData, 'came ' + sData + ':' + _m(ChatUsers[tag]) + ChatUsers[tag].m_Nick + CrLf);
// Add this chat to the user's chat list
for n := Low(ChatUsers[tag].m_Chats) to High(ChatUsers[tag].m_Chats) do
if ChatUsers[tag].m_Chats[n] = '' then
begin
ChatUsers[tag].m_Chats[n] := sData;
b := True;
Break;
end;
// If we got here all slots are full, append one
if b = False then
begin
SetLength(ChatUsers[tag].m_Chats, High(ChatUsers[tag].m_Chats)+2);
ChatUsers[tag].m_Chats[High(ChatUsers[tag].m_Chats)] := sData;
end;
// send chat info
rSocket.SendText('joined ' + sData + CrLf +
'mem ' + sData + ':' + ChatMembers(sData) + CrLf);
if ShowMovement.Checked then
AddText('> ' + rSocket.RemoteAddress + ':Joined ' + sData);
end // Leaves a chatroom
else if sCommand = 'leave' then // in: leave room
begin // out: left room:user
if sData = '' then
goto TheSkipper;
for n := Low(ChatUsers[tag].m_Chats) to High(ChatUsers[tag].m_Chats) do
if ChatUsers[tag].m_Chats[n] = sData then
begin
ChatUsers[tag].m_Chats[n] := '';
SpreadChat(sData,
'left ' + sData + ':' + ChatUsers[tag].m_Nick + CrLf);
rSocket.SendText('fled ' + sData + CrLf);
if ShowMovement.Checked then
AddText('> ' + rSocket.RemoteAddress + ':Left ' + sData);
goto TheSkipper;
end;
rSocket.SendText('error You are not in this room' + CrLf);
end
else if sCommand = 'afk' then
begin
ChatUsers[tag].m_Idle := True;
ModeChange(ChatUsers[tag]);
end
else if sCommand = 'afkoff' then
begin
ChatUsers[tag].m_Idle := False;
ModeChange(ChatUsers[tag]);
end
else if sCommand = 'op' then // op user
begin
sData := _l(sData);
if sData = '' then
goto TheSkipper;
if not IsUserOn(sData) then
begin
rSocket.SendText('error User is not logged in' + CrLf);
goto TheSkipper;
end;
if ChatUsers[tag].m_Mode = 1 then
for n := low(ChatUsers) to high(ChatUsers) do
if ChatUsers[n].m_InUse then
if _l(ChatUsers[n].m_Nick) = sData then
begin
ChatUsers[n].m_Mode := 1;
ModeChange(ChatUsers[n]);
end;
end
else if sCommand = 'boot' then // boot user
begin
sData := _l(sData);
if sData = '' then
goto TheSkipper;
if not IsUserOn(sData) then
begin
rSocket.SendText('error User is not logged in' + CrLf);
goto TheSkipper;
end;
if ChatUsers[tag].m_Mode = 1 then
for n := low(ChatUsers) to high(ChatUsers) do
if ChatUsers[n].m_InUse then
if _l(ChatUsers[n].m_Nick) = sData then
begin
Server1.Socket.Connections[_s(ChatUsers[n])].Close();
RemoveUser(ChatUsers[n]);
end;
end
else if sCommand = 'pm' then // pm user:message
begin
n := InStr(1, sData, ':');
if n = 0 then
goto TheSkipper;
s := _l(mid(sData, 1, n-1));
s2 := trim(mid(sData, n+1));
if s = '' then
goto TheSkipper;
if s2 = '' then
goto TheSkipper;
if not IsUserOn(s) then
begin
rSocket.SendText('error User is not logged in' + CrLf);
goto TheSkipper;
end;
if length(s2) > 1000 then
s2 := mid(s2, 1, 1000);
if s2 = '' then
goto TheSkipper;
for n := low(ChatUsers) to high(ChatUsers) do
if ChatUsers[n].m_InUse then
if _l(ChatUsers[n].m_Nick) = s then
begin
Server1.Socket.Connections[_s(ChatUsers[n])].SendText(
'gotpm ' + ChatUsers[tag].m_Nick + ':' + s2 + CrLf);
end;
end
else if sCommand = 'line' then // line chat:linedata
begin
inc(ChatUsers[tag].m_DrawCount);
if ChatUsers[tag].m_DrawCount = 100 then
rSocket.SendText('dlg Please go easy on the multi-user drawing board' + CrLf);
if ChatUsers[tag].m_DrawCount < 150 then
begin
n := InStr(1, sData, ':');
if n = 0 then
goto TheSkipper;
s := mid(sData, 1, n-1);
SpreadChatNoMe(s, ChatUsers[tag].m_Nick, 'line ' + sData + CrLf);
end;
end
else if sCommand = 'list' then // list
begin
for n := 0 to ChatList.Count - 1 do
rSocket.SendText('list ' + ChatList.Strings[n] + CrLf);
end
else if sCommand = 'pong' then // pong
begin
ChatUsers[tag].m_Ponged := True;
end;
TheSkipper:
end;
end;
end;
[/code]
thanks alot
Slewis
Comments
However you have not completed it by using "Except or Finally" (see code marked in red)
James
: ok i have a problem with my code when i try to compile i get the
: following errors [ EXCEPT OR FINALLY expected ] and [ ';' expected
: but ',' found ]
:
: can anyone help?
:
: [code]:
: procedure TForm1.RunCommand(ss: string; rSocket: TCustomWinSocket);
: var
: nnn, n, n2, j, i: integer;
: black, found: boolean;
: sss, s1, s2, s3, s4, s5, s: string;
: com: string;
: tag, l, nSpace: Integer;
: NewData, sCommand, sData: String;
: b: Boolean;
: label
: TheSkipper;
: begin
:
: sss := ss;
: [color=Red][b]try[/b][/color]
: if (length(sss) > 3) then
: sss := DecodeStr(sss)
: else
: exit;
: nnn := 0;
: while (DecodeCommand(sss, scommand, sdata)) and (nnn < 1000) do
: begin
: nnn := nnn + 1;
: s := '';
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[/code]