Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Rafael Escambion
  Where is Rafael Escambion?
 Nouadhibou
 Mauritania
 Rafael Escambion
 Tags
Subject: RE: Deny Access in some Menu items
Thread ID: 200698 Message ID: 200975 # Views: 49 # Ratings: 0
Version: Visual FoxPro 9 Category: Menus
Date: Thursday, October 30, 2008 6:41:11 PM         
   


> In the main PRG, declare a public variable.
>
>
> Public pRights
> 

>
>
> Now in your LOG IN form, assign a value to it accordingly.
>
>
> pRights = UserTable.URights  && can be logical or numeric
> 

>
>
> In your menu, you can use Skip For pRights = [logical or numeric]


You are right, that would work.
As for the Public declaration itself - as you know, there have been a few public discussions already here and elsewhere and many people say "Public variables are bad".
Why do they say so? Long story of course - often Public variables are misused when form.properties would be better. That's not the case here of course.
Another point is that when in your example you'd create an undeclared variable in "main.prg" instead of the Public one, and additionally use the Private keyword, you would be able to do an Do your.EXE inside your.EXE itself (rare requirement).

My personal reason not to use Public here would be that when we need an m.pRights variable, we may also want an pUserName and perhaps a pUserID, and perhaps even a NewUserLogin() procedure, and in other contexts we might need other variables and would end up with 10 or 30 of them, and they would be created and assigned and accessed all over all project files and it would get difficult to maintain them.

That's why the OOP concept would suggest using classes and create objects at runtime. Such an object would be a "boxed" module with an easy "interface", hiding all complexity so that it's easy to use.
Still that object, say goApp, would need to be in scope for the entire application - so you can again use the "Private" keyword and createobject() it in an undeclared variable in main.prg
Afterwards, in the menu, you can use Skip For ( Type("m.goApp.nUserLevel")<>'N' OR m.goApp.nUserLevel < 5 )


hth
-Stefan



COMPLETE THREAD
Deny Access in some Menu items Posted by Prasant T @ 10/29/2008 1:49:34 PM
RE: Deny Access in some Menu items Posted by surinder singh @ 10/29/2008 1:52:52 PM
RE: Deny Access in some Menu items Posted by tushar @ 10/29/2008 1:54:31 PM
RE: Deny Access in some Menu items Posted by Benny Thomas @ 10/31/2008 10:04:30 AM
RE: Deny Access in some Menu items Posted by tushar @ 10/31/2008 11:41:06 AM
RE: Deny Access in some Menu items Posted by Yousfi Benameur @ 10/29/2008 2:09:58 PM
RE: Deny Access in some Menu items Posted by Jun Tangunan @ 10/30/2008 7:13:05 AM
RE: Deny Access in some Menu items Posted by Rafael Escambion @ 10/30/2008 7:47:23 AM
RE: Deny Access in some Menu items Posted by Stefan Wuebbe @ 10/30/2008 6:41:11 PM
RE: Deny Access in some Menu items Posted by Glenn Villar @ 10/31/2008 2:03:23 AM
RE: Deny Access in some Menu items Posted by Stefan Wuebbe @ 10/31/2008 8:54:37 AM
RE: Deny Access in some Menu items Posted by Marcia Akins @ 11/1/2008 12:40:31 PM
RE: Deny Access in some Menu items Posted by Prasant T @ 11/3/2008 8:21:35 AM
RE: Deny Access in some Menu items Posted by Biju Thomas @ 12/3/2008 4:38:27 AM