Results 1 to 5 of 5

Thread: Problems with needed subroutines...

  1. #1

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Problems with needed subroutines...

    If you couldn't already tell, I'm a serious VC++ noob, so bear with me...


    Working on a mudd game, details are fairly irrelevant, but I don't know how to get a bunch of different menus in the same program without errors.

    The other thing is that one of the first menu options, "New Game", isn't working for some reason. All that option should be is some cout commands and a menu call, but I keep getting errors on the compile. Can someone just post me some code with multiple menu calls and a text-only option that calls another menu instead of creating one?

  2. #2
    Hyperactive Member
    Join Date
    Jan 2003
    Location
    The Netherlands
    Posts
    386

    Re: Problems with needed subroutines...

    Are you talking about a geniune Windows program menu as in "File, Edit, View...etc", or are you talking about a basic text printed menu that will get input like this:


    [A]ttack
    [B]lock
    [R]un
    [U]se Item
    >...

  3. #3

    Thread Starter
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Problems with needed subroutines...

    #include <iostream.h>


    Pure DOS, nothing else. I just started it a couple days ago, so I'm not into anything big. Just cout<< and cin>> stuff...

  4. #4
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: Problems with needed subroutines...

    well you won't be making a MUDD anytime soon.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  5. #5
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Re: Problems with needed subroutines...

    Hopefully this will help you to get started I grabbed it from something I wrote a while back.

    Displaying the main menu(s)...
    Code:
    ldBOOL LetsDecideClient::DoLogin()
    {
    	while(true)
    	{
    		system("cls");	//windows only
    		cout<<"----------------------------"<<endl;
    		cout<<"-----Let's Decide Login-----"<<endl;
    		cout<<"----------------------------"<<endl;
    		cout<<"Please enter your username:";
    		cin>>myUser.userName;
    		cout<<"Please enter your password:";
    		cin>>myUser.password;
    		myUser.userID = 0;
    		myUser.isManager = ldFALSE;
    		
    		if(!myServer.LogIn(myUser.userName, myUser.password, myUser.userID, myUser.isManager))
    		{
    			char	temp;
    			
    			do
    			{
    				DisplayLastFailure();
    				
    				cout<<"Would you like to retry (y/n)?";
    				cin>>temp;
    			}
    			while((temp != 'y') && (temp != 'n'));
    			
    			if(temp == 'n')
    			{
    				return ldFALSE;
    			}
    		}
    		else
    		{
    			return ldTRUE;
    		}
    	}
    }
    
    char LetsDecideClient::DisplayMainMenu()
    {
    	char temp;
    	
    	system("cls");	//windows only
    	cout<<"--------------------------------"<<endl;
    	cout<<"-----Let's Decide Main Menu-----"<<endl;
    	cout<<"--------------------------------"<<endl;
    	cout<<"(P)oll selection"<<endl;
    	
    	if(myUser.isManager)
    	{
    		cout<<"Check login (f)ailures"<<endl;
    		cout<<"(S)end notification"<<endl;
    		cout<<"Add/Modify (u)ser"<<endl;
    		cout<<"Add/Modify p(o)ll"<<endl;
    	}
    	
    	cout<<"(Q)uit"<<endl;
    	cout<<"--------------------------------"<<endl;
    	cout<<"Select an option:";
    	cin>>temp;
    	
    	return temp;
    }
    Catching keystrokes from the main menu...
    Code:
    char mainSelection, mainLogin;
    	
    	do
    	{
    		mainLogin = DisplayLogin();
    		switch(mainLogin)
    		{
    		case 'q':
    		case 'Q':
    			break;
    		case 'l':
    		case 'L':
    			if(DoLogin())
    			{
    				do
    				{
    					mainSelection = DisplayMainMenu();
    					
    					switch(mainSelection)
    					{
    					case 'p':
    					case 'P':
    						DisplayPollSelection();
    						break;
    					case 'q':
    					case 'Q':
    						DoLogout();
    						break;
    					case 'f':
    					case 'F':
    						if(myUser.isManager) 
    						{
    							DisplayFailures();
    							break;
    						}
    					case 's':
    					case 'S':
    						if(myUser.isManager) 
    						{
    							DoNotify();
    							break;
    						}
    					case 'u':
    					case 'U':
    						if(myUser.isManager) 
    						{
    							DisplayUserMenu();
    							break;
    						}
    					case 'o':
    					case 'O':
    						if(myUser.isManager)
    						{
    							break;
    						}
    					default:
    						cout<<"You have not selected a valid option!"<<endl;
    						sleep(1000);
    						break;
    						//system("pause");	//Windows only
    					}
    				}
    				while((mainSelection != 'q') && (mainSelection != 'Q'));
    			}
    			break;
    		default:
    			cout<<"You have not selected a valid option!"<<endl;
    			sleep(1000);
    			break;
    		}
    		  }
    		  while((mainLogin != 'q') && (mainLogin != 'Q'));
    		  
    		  cout<<endl<<"------------------------------"<<endl;
    		  cout<<"Thanks for using Let's Decide!"<<endl;
    		  cout<<"------------------------------"<<endl;
    		  cout<<"By: The Flapping Cats"<<endl;
    		  sleep(2000);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width