Buddies Buddies!

I added a buddies list to my project and I been trying alldo to finger out how to make a Yes/No funcation to allow or disallow people from being added to there buddies list on my chat I got a working code well I say working it works fine untill the part were there say YES to add and then it dont add the person I will post the full code here starting with client funcations first.

when a person right clicks on a username to send a request to add to buddies list it calls the following :

// start
procedure TChatForm.Add1Click(Sender: TObject);
begin
if DM.UserName = PopupName then
begin
 Showmessage('Why do you want to add your self?');
 Exit;
end
else
begin
if DM.MainClient.active then
   DM.MainClient.Socket.SendText(CodeStr('šRequestBuddiesAddœ'+
   DM.UserName +'œ'+ PopupName +'œ'));
 end;
end;
// end

then that is send to the server with your current nick and the person you wish to add to list

// start

      if com = 'RequestBuddiesAdd' then
      try
      for j := 0 to MainServer.Socket.ActiveConnections - 1 do
      begin
      if MainServer.Socket.Connections[j] <> nil then
      if MainServer.Socket.Connections[j].Connected then
      if lowercase(MainServer.Socket.Connections[j].Name) = lowercase(dat[1]) then
              begin
                MainServer.Socket.Connections[j].SendText(
                  CodeStr('šRequestBuddiesœ' + dat[0]
                  + 'œ' + dat[1] + 'œ')); // send request back to client to show popup with your nick and person you wish to add
              end;
            end;
        except
      end;

// end

Then is comes back to the client and shows the YES/NO window

// start

{
  dat[0] is your account name
  dat[1] is the person you would like to add to your buddies list.
}

   if (com='RequestBuddies') then
   begin
   if MessageDlg(dat[0]+' Would like to add you to there buddies list.',
      mtInformation, [mbYes, mbNo], 0) = mrYes then
   begin
   if DM.MainClient.active then
      DM.MainClient.Socket.SendText(CodeStr('šAddCListœ'+ dat[0] +'œ'+ dat[1] +'œ')); // if YES then it will send to server your nickname and the person to add!
   end;
end;

// end

Then the server would call on the following funcation to send to client to add username to buddies list

// start

 if com = 'AddCList' then
        if dat[0] <> '' then
          if dat[1] <> '' then
            try
              if UsersTable.Locate('Name', dat[0], [locaseinsensitive]) then
              begin
                if ClLocate(dat[1], rSocket) = False then
                begin
                  rSocket.CL.Add(dat[1]);
                  UsersTable.Edit;
                  UsersTable.FieldByName('CL').AsString := rSocket.CL.Text;
                  UsersTable.Post;
                  s := '';
                  for j := 0 to MainServer.Socket.ActiveConnections - 1 do
                  begin
                    if MainServer.Socket.Connections[j] <> nil then
                      if MainServer.Socket.Connections[j].Connected then
                        if lowercase(MainServer.Socket.Connections[j].Name) =
                          lowercase(dat[1]) then
                        begin
                          s :=
                            'šCLOnLineœ' + MainServer.Socket.Connections[j].Name +
                            'œ' + MainServer.Socket.Connections[j].Country +
                            'œ' + MainServer.Socket.Connections[j].Sex +
                            'œ' + MainServer.Socket.Connections[j].Age +
                            'œ' + MainServer.Socket.Connections[j].Status +
                            'œ' + MainServer.Socket.Connections[j].Typ +
                            'œ' + MainServer.Socket.Connections[j].Expir +
                            'œ' + MainServer.Socket.Connections[j].RDot +
                            'œ' + MainServer.Socket.Connections[j].color + 'œ';
                          break;
                        end;
                    if s = '' then
                      s := 'šCLOffLineœ' + dat[1] + 'œ';
                  end;
                  if rSocket <> nil then
                    if rSocket.Connected then
                      rSocket.SendText(CodeStr(s));
                end;
            end;
    except
end;

// end

Then client would do the last part and add your buddie to your list

// start

   if (com='CLOnLine') then
   if dat[0]<>'' then
    begin
//  if (PUserTable.Locate('Name',dat[0],[]))then
      begin
       if AUserTable.Locate('Name',dat[0],[])=false then
        begin
         AUserTable.Append;
         AUserTable.FieldByName('Name').AsString:=dat[0];
         AUserTable.FieldByName('Country').AsString:=dat[1];
         AUserTable.FieldByName('Sex').AsString:=dat[2];
         AUserTable.FieldByName('Age').AsString:=dat[3];
         AUserTable.Post;
         if MainForm<>nil then MainForm.VTSAppend('AIM',dat[0],dat[8],'1');
        end
       else
         if MainForm<>nil then MainForm.VTSEdit(dat[0],'1');
       if (PUserTable.Locate('Name',dat[0],[]))then
        begin
       PUserTable.Delete;
       if MainForm<>nil then MainForm.VTSDelete('PIM',dat[0]);
        end;
       if MainForm<>nil then MainForm.VTS.repaint;
      end;
    end;

// end


Can anyone please help me I really dont no were the problem is I debuged and all the right names are being sent so on it just will not add the name to list once you press YES!

there is a full 500 points to person that helps find the problem cheers
fiveukAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

calinutzCommented:
So ... you tried placing a memo on the server side and another memo on the client side and code them to add their activities inside the memos? Because the problem may come from the data you send.

Also try executing the table append independently from the rest of the code to see it work
Also the clients should refresh their list after doing a request to the server.
Check the table in the server after the request, not the client side list because it may not refresh corectly
I can see that you are using VirtualTree, nice. You should first make it work using simpler components so it wouldn't complicate your problem

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fiveukAuthor Commented:
I did that with memo and like Isays it sends all the correct data back to server and client I added popup messages to follow the da[0].dat[1] and a message on server to log events everything works from calling the Accept window so on its just when I say YES on the window it dont add the persons name.
fiveukAuthor Commented:
I fixed the problem thanks alot for the help matey
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.