Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-11-2005, 06:36 PM   #1 (permalink)
bradleyc
Registered User
 
Join Date: Aug 2005
Posts: 17
bradleyc is on a distinguished road
Why?

Code:
           else
       	  {
           cout << "                      " << endl;
           cout << "  -- New Record --    " << endl;
           cout << "  What is the Video Number?: ";
           cin >> videoLib[location1].videoNum;
           cout << "  What is the Video Name?: ";
           cin.getline(videoLib[location2].videoName, 30);
           cin.ignore();
           displayMenu();
Why doesnt it go back to the displayMenu() module?
bradleyc is offline   Reply With Quote
Old 09-11-2005, 07:18 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
How about posting the compilable code?
__________________
Valmont is offline   Reply With Quote
Old 09-11-2005, 07:23 PM   #3 (permalink)
bradleyc
Registered User
 
Join Date: Aug 2005
Posts: 17
bradleyc is on a distinguished road
Code:
void doModify()
{
   clrscr();
   char inputv, input1, input2;
   cout << "                      " << endl;
   cout << "  --- MODIFY VIDEO MENU ----                 " << endl;
   cout << "  Would you like to modify a video (y/n)?: ";
   cin >> inputv;
   if (inputv == 'y' || inputv == 'Y')
   {
       	clrscr();
       	int item1, location1, location2;
       	char item2[20];
       	cout << "                      " << endl;
       	cout << "  -- Current Record --    " << endl;
       	cout << "  What is the Video Number?: ";
       	cin >> item1;
       	location1 = searchNum(videoLib, numElements, item1);
       	if (location1 == -1)
       	{
          clrscr();
          cout << "                      " << endl;
          cout << "  Invaild Input" <<endl;
          cout << "  Press any key to exit ....";
          input1 = getch();
          displayMenu();
        }
       	else
       	{
       	  cout << "  What is the Video Name?: ";
      	  cin >> item2;
      	  location2 = searchName(videoLib, numElements, item2);
       	  if (location2 == -1)
       	  {
            clrscr();
            cout << "                      " << endl;
            cout << "  Invaild Input" <<endl;
            cout << "  Press any key to exit ....";
	    		input2 = getch();
            displayMenu();
          }
          else
       	  {
           cout << "                      " << endl;
           cout << "  -- New Record --    " << endl;
           cout << "  What is the Video Number?: ";
           cin >> videoLib[location1].videoNum;
           cout << "  What is the Video Name?: ";
           cin.getline(videoLib[location2].videoName, 30);
           cin.ignore();
           displayMenu();
	   }
	}
  }
    	else if (inputv == 'n' || inputv == 'N')
   	displayMenu();
}
bradleyc is offline   Reply With Quote
Old 09-12-2005, 04:06 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
You're displaying menu in every single one cases, why not rearrange the code a bit:
Code:
void doModify()
{
  clrscr();
  char inputv, input1, input2;
  cout << "                      " << endl;
  cout << "  --- MODIFY VIDEO MENU ----                 " << endl;
  cout << "  Would you like to modify a video (y/n)?: ";
  cin >> inputv;
  if (inputv == 'y' || inputv == 'Y')
    {
      clrscr();
      int item1, location1, location2;
      char item2[20];
      cout << "                      " << endl;
      cout << "  -- Current Record --    " << endl;
      cout << "  What is the Video Number?: ";
      cin >> item1;
      location1 = searchNum(videoLib, numElements, item1);
      if (location1 == -1)
       	{
          clrscr();
          cout << "                      " << endl;
          cout << "  Invaild Input" <<endl;
          cout << "  Press any key to exit ....";
          input1 = getch();
        }
      else
       	{
       	  cout << "  What is the Video Name?: ";
      	  cin >> item2;
      	  location2 = searchName(videoLib, numElements, item2);
       	  if (location2 == -1)
	    {
	      clrscr();
	      cout << "                      " << endl;
	      cout << "  Invaild Input" <<endl;
	      cout << "  Press any key to exit ....";
	      input2 = getch();
	    }
          else
	    {
	      cout << "                      " << endl;
	      cout << "  -- New Record --    " << endl;
	      cout << "  What is the Video Number?: ";
	      cin >> videoLib[location1].videoNum;
	      cout << "  What is the Video Name?: ";
	      cin.getline(videoLib[location2].videoName, 30);
	      cin.ignore();
	    }
	}
        displayMenu();
    }
    else if (inputv == 'n' || inputv == 'N')
        displayMenu();
}
In your version it's the same flow you're getting, here theres only one place where you have to concentrate on showing the menu, much more friendly for later maintanence..
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 09-12-2005, 05:09 AM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
I have a suspicion. Give the rest please. Make my life easy . Imagine I am doing many things from behind my desk. Only one of them is coding for codenewbie. That's why I like things easy. Give me working compilable code. Out of courtesy, peeps should always post the compilable version that represents the whole problem set.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:21 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting