Solved

problems with message

Posted on 2006-10-20
8
162 Views
Last Modified: 2010-04-05
I been trying to stop accounts from joining any public rooms but I want it so it will check rooms and if the room is 'Support Room' it will allow them to join but any thing else it would reject them anyone got any idears??

dat[0] gets current room name
 (Dm.UserTyp='2')  is account level I wish to stop from accessing rooms


[code]
   if (dat[0]=dat[0]) // Check room names
      and
      (Dm.UserTyp='2') // Check account level
   then
   begin
     Showmessage('Sorry!, Help Accounts are unable to access public areas.');
     Exit;
   end
   else
begin


hope sumone can help thanks
0
Comment
Question by:fiveuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 1

Expert Comment

by:malsoft
ID: 17774488
From your code stub, it looks like you are testing for equality on the same thing at the start ( dat[0] = dat[0] ), that would always be true ( e.g. "1" = "1" and "aaa" = "aaa" etc). If dat[0] contains the room name, maybe you need the following test:

if (dat[0] = {name of support room} ) and (Dm.UserTyp = '2') then
...
0
 

Author Comment

by:fiveuk
ID: 17774757
ok following code stops me from entering support room

   if (dat[0] = 'English Help') // Check room names
      and
      (Dm.UserTyp='2') // Check account level
   then

but I want to be able to enter that room and thing other then English Help would get the error msg!
0
 
LVL 28

Expert Comment

by:TName
ID: 17774861
I'm not sure I understand you. Do you want anyone with UserTyp 2 to ONLY be able to enter the supportroom?

if (dat[0] <> 'Support Room')  and  (Dm.UserTyp='2')
   then begin
     Showmessage('Sorry!, Help Accounts are unable to access public areas.');
     Exit;
   end
   else begin
     //
   end;
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:fiveuk
ID: 17774901
no I would like it so anyone with UserTyp='2' will not to be able to enter any room other then Support Room
0
 
LVL 28

Expert Comment

by:TName
ID: 17774945
>no I would like it so anyone with UserTyp='2' will not to be able to enter any room other then Support Room
I think that's exactly what I said :)

if (dat[0] <> 'Support Room')   //if room is any other than support room
   and                                     //and at the same time
   (Dm.UserTyp='2')                //user type is 2
   then begin                           //then reject  
     Showmessage('Sorry!, Help Accounts are unable to access public areas.');
     Exit;
   end
   else begin
     //
   end;
0
 
LVL 1

Accepted Solution

by:
malsoft earned 125 total points
ID: 17774956
OK, looks like you may want to reverse the logic for the tests. The limiting factor (UserTyp = '2') should be checked first, not what board you are in:

if (Dm.UserTyp = '2') then  // restricted accounts
begin
  if (dat[0] <> 'English Help') then
  begin
    ShowMessage('Sorry...');
    Exit; // leaves routine
  end;

  // continue with "support" options from here...
end
else begin  // non-restricted accounts
...
end;
0
 

Author Comment

by:fiveuk
ID: 17775041
Ok that worked fine but now the problem is all other accounts can not access rooms lol here full code

[code]

if (com='RJoinRoom')then
begin
  if ChatFormTable.Locate('Name',dat[0],[])=false then
  begin
  if (Dm.UserTyp = '2') then  // restricted accounts
  begin
  if (dat[0] <> 'English Help') then
  begin
    Showmessage('Sorry!, Help Accounts are unable to access public areas.');
    Exit; // leaves routine
  // continue with "support" options from here...
end
else begin  // non-restricted accounts
    if NewRForm<>nil  then NewRForm.Close;
    if EnterForm<>nil then EnterForm.Close;
//    if ListForm<>nil  then ListForm.Close;
    if ChatFormTable.Locate('Name',dat[0],[])=false then
     begin
      Application.CreateForm(TChatForm, CForm0);
      CForm0.Name:='chat'+inttostr(CForm0.handle);
      if ChatFormTable.RecordCount=0 then CForm0.media:=true else CForm0.media:=false;
      ChatFormTable.Append;
      ChatFormTable.FieldByName('Name').AsString:=dat[0];
      ChatFormTable.FieldByName('FormName').AsString:=CForm0.Name;
      ChatFormTable.Post;
      CForm0.RoomName:=dat[0];
      CForm0.GroupName:=dat[2];
      CForm0.Caption:=dat[0];
      MyHand:=False;
      Speak:=false;
//      if pos('SPEEX',uppercase(dat[6]))>0 then dat[6]:=copy(dat[6],pos('SPEEX',uppercase(dat[6]))+5,length(dat[6]));
      CForm0.Codec:=dat[6];
      CForm0.PrepareCodec(dat[6]);
      CForm0.Show;
      if (Dm.UserTyp='2')or(Dm.UserTyp='3')then
        CForm0.ChatPopup.Items[4].Visible:=true
      else
       CForm0.ChatPopup.Items[4].Visible:=false;
      if dat[1]='1' then
       begin
        CForm0.Owner:=true;
        CForm0.ChatPopup.Items[4].Visible:=true;
       end
      else
       CForm0.Owner:=false;
      CForm0.SKForm.Caption:=dat[0];
      s:='šGetChatUsersœ'+dat[0]+'œ';
      Socket.SendText(CodeStr(s));
     end
    else
     begin
      CForm0:=Application.FindComponent(ChatFormTableFormName.AsString) as TChatForm;
      if CForm0<>nil then
       begin
        if CForm0.UserTable.Locate('Name',DM.UserName,[])then
         begin
          CForm0.UserTable.Append;
          CForm0.UserTable.FieldByName('Name').AsString:=DM.UserName;
          CForm0.UserTable.FieldByName('Owner').AsString:=dat[1];
          CForm0.UserTable.Post;
          if dat[1]='1' then
           CForm0.VTSInsert(dat[0],dat[1],dat[3],dat[4],'0','0',dat[7])
          else
           CForm0.VTSAppend(dat[0],dat[1],dat[3],dat[4],'0','0',dat[7]);
         end;
         end;
       end;
     end;
     end;
   end;
end;
0
 

Author Comment

by:fiveuk
ID: 17775245
Ok i fixed it thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question