Solved

problems with message

Posted on 2006-10-20
8
158 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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