Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable or hide an item in a .mnx file?

Status
Not open for further replies.

pxw

Programmer
Jan 6, 2002
86
AU
Is there any programable way to disable or hide an item in a .mnx menu file? For instance, menu TEST.mnx has two items,

INVOICE procedure
SETUP submenu

What I want is,
- The INVOICE section can be accessed by every user.
- The SETUP submenu can be accessed only by the authorized users, which is controlled by the VFP app.

Any help would be greately apprecaited.


Peter
 
pxw

Click on the Options button

In the "Skip for:" textbox, enter an expression that, when the expression is true, will disable the selection, such as:-

USER.permission = .F.

if the user has permission, OK to use the menu selection.
HTH

Chris [pc2]
 
hi Chris,

Many thanks. That is what I want to know.


Peter
 
Peter,
Well, you've opened a big can of worms here... The short answer to your question is, yes, it can be controlled programatically, as you have descirbed. In a broader term, however, you are going to need to impliment a couple of things.
First, the menus can be controled for activation/deactivation via the Skip For builder. You go to it by clicking the square box to the right of the menu option in the menu builder, and then place your code in the Skip For edit box, or click the ... box next to the cluase, which will take you to the Skip For expression builder.
This is where it gets tricky. You will need to create some type of "Security" to identify the level of user you want, and then compare that in your Skip For clause. You'll need a way to identify the user, and identify the "Level" that you want. You can do this in a number of ways, ethter using numeric "Level" numbers, or Ture/False type "Permissions". That is up to you.
Sorry this is more a theoretical answer, but your question doesn't lend itself to a quick one-or-two lines of code type answer. You should really think about what you need in this case, and then proceed from there.
Best Regards,
Scott

Please let me know if this has helped [hammer]
 
hi Scott,

You are right. I am using a program in my app to identify users using numeric "Level" numbers. It works okay. What I want to do is to use it for menu as well.


Peter

 
Keep in mind that the menu SKIP FOR expressions are all evaluated every time the user tries to open ANY menu. This has positive and negative effects.

On the plus side, you can dynamically enable/disable any menu item by changing the variable. I commonly use this to disable forms that are already open:
[tt]
Skip for: WEXIST("myform")
[/tt]
On the minus side, any variables referenced in the menu system must be in scope any time the user has access to the menu. This is typically handled by global variables or objects. If that variable goes out of scope and the user clicks on the menu, he/she will receive a series of "Variable XX is not found", one for every menu item that contains it. Those SKIP FOR expressions will be ignored from then on.

Also on the minus side, complex functions can severely hamper your system's performance. If you use a function in the SKIP FOR clause that scans through tables, for instance, it's going to do so after the user clicks the menu and before the menu is actually displayed.

Hope that helps,

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top