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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading menus

Status
Not open for further replies.

CleoMan

Programmer
Jun 18, 2003
110
ZA
I have created two menus in paradox using the menu editor. The one is for the adminastrator allowing access to accounting features. The second menu is only for users that need to insert data (ie: they cannot acces the accounting functions).

At the start of my program I ask the user name and password as to determine what kind of user is logging on (admin or normal).

Now I would like to know how do I go about loading the different menu's for the two types of users?

Any advice or ideas is greatly appreciated, thanks.
 
There are several ways you could approach this, depending on what you prefer. If the menus are completely different then I would use a conditional branch (like switch/case) in the Arrive and MenuAction sections, essentially having two sets of commands that are used based on some 'user type' variable you assign after the password and username are accepted. The other alternative would be to simply disable the admin menu commands (MenuDisabled, MenuGrayed) for the regular users.





Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
CleoMan,

Something like this should work:

Code:
var
   strUserName  String
endVar

   strUserName = athenticateUser()
   if strUserName = "admin" then
      showAdminMenu()
   else
      showDataEntryMenu()
   endIf

This would probably go into the form's init() event. AthenticateUser, showAdminMenu, and showDataEntryMenu() are all custom procedures that, well, do what their names sounds like. The first handles the process of obtaining the password, the second displays the admin menu, and the third displays just the data entry menu.

Alternatively, you could consolidate the last two into a single routine that selectively adds admin commands to your menu if the user has admin privledges.

Hope this helps...

-- Lance
 
OK, I am sorry to ask this but what would the actual code look like for loading a premade menu?

A stupid question I know, but this is the part I cant get working (the logic is not really the problem )

Thanks
richard
 
Here is an example I cut and pasted from one of my apps I butchered it a little for clarity, but you can see how it works:

------- FORM ARRIVE EVENT

Code:
method arrive(var eventInfo MoveEvent)

if eventInfo.isPreFilter() then
  ;// This code executes for each object on the form

  else
	;// This code executes only for the form

      popSys.addText("E&xit")
      popSys.addText("&Presets")
      popSys.addSeparator()
      popSys.addText("&Issue Warning")
      popSys.addSeparator()
      popSys.addText("&Data Transfer")
      m.addPopUp("&System",popSys)
      m.show()
      endIf

endMethod

----- FORM MENUACTION EVENT

Code:
method menuAction(var eventInfo MenuEvent)
var
myform	form
myHelpFile	String
userChoice	string
ptCursor	tCursor
endvar

if eventInfo.isPreFilter() then
;// This code executes for each object on the form

   else
	;// This code executes only for the form

  	sAns=eventinfo.menuChoice()

	switch
	case sAns="E&xit":close() ;exit()
        case sAns="&Presets":
      	   myForm.openAsDialog(":Citations:Preset")
        case sAns="&Issue Warning":
      	   myForm.openAsDialog(":Citations:Warnings")
        case sAns="&Data Transfer":
      	   ;FTPXfer()
        endswitch

endIf

endMethod

Mac :-)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
I don't know what caused that little "Y" with the two dots, it does not belong there.



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top