void displayMenu() { char choice; system("cls"); printf("[1]-DISPLAY ALL\n[a]-NEXT\n[d]-PREVIOUS\n"); printf("PRESS ESC TO RETURN TO MAIN MENU...\n"); choice=getch(); switch(choice) { case '1': displayArray(); getch(); displayMenu(); break; case 'a': nextItem(); getch(); displayMenu(); break; case 'd': prevItem(); getch(); displayMenu(); break; default: askUser(); break; } }
int updateMainWin() { int ch = 0; switch (mainWinState) { case MSW_INIT: resetMenuPos(); displayMenu(mainWin); mainWinState = MWS_IDLE; break; case MWS_IDLE: logPrint("Waiting for command to begin or quit\n"); ch = wgetch(mainWin); if (ch == 'b' || ch == 'B') { moveMenuHorizontal(1);// highlight the first menu item in the first run. displayMenu(mainWin); mainWinState = MWS_MENU_NAV; } break; case MWS_MENU_NAV: ch = wgetch(mainWin); menuNavigate(ch); displayMenu(mainWin); //printMenuGraph(); break; case MWS_PRINT: break; } return 0; }
/* ;*********************************************************************** ; Name: checkMenuInputs ; Description: Check if the Joysticks have transitioned from below ; the specified threshold to above it for both the up ; and down directions. Essentially, we want to check ; a transition from the netural area in the middle to ; the top or bottom (Up/Down). Note that we pass by ; value to this function instead of using the global ; variable because it could change in the middle of ; this function call. ; ; D 0v -> (2.5v - ZEROTHRESH) ; M (2.5v - ZEROTHRESH) -> (2.5 + ZEROTHRESH) ; U (2.5v + ZEROTHRESH) -> 5v ; ;***********************************************************************/ void checkMenuInputs(char joyin) { // use a static variable so we can reuse the value when we return // to this function. This was used as apposed to a global variable // because we don't want anyone else modifying this value. static char prevleft = 0; static char joyvertprev = 0; // Check pushing joystick up if ( joyin < THRESHUP ) { if ( joyvertprev > THRESHUP ) { selection--; displayMenu(selection); } // don't allow the selection to overflow if (selection < 0) { selection = 0; } } // Check pushing joystick down if ( joyin > THRESHDO ) { if ( joyvertprev < THRESHDO ) { selection++; displayMenu(selection); } // don't allow selection to underflow if (selection > 3) { selection = 3; } } // Check for button push (check if selection confirmed) if ( (PTAD & LEFTPB) == 0 ) { if (prevleft == 1) { select = 1; } prevleft = 0; } else if ( (PTAD & LEFTPB) == LEFTPB) { prevleft = 1; } // update previous value joyvertprev = joyin; }
void MenuClass::doMenu() { cancelFlag = checkForCancel(); if (runningFunction) { runningFunction = !runFunction(); } else { //menuHandler(); cancelFlag = false; int selUp = updateSelection(); if (selUp) { currentItemIndex += selUp; // Avoid negative numbers with the modulo // to roll the menu over properly while (currentItemIndex < 0) { currentItemIndex += currentMenu->getSize(); } currentItemIndex %= currentMenu->getSize(); } else { // only check for selection if menu not also updating if (selectionMade()) { // selection made, run item function once now if (!runFunction()) { // If item function returns false then it isn't done and we need to keep running it. runningFunction = true; return; // skip displaying the menu if we're going to run item function again. } } } displayMenu(); } }
void UserInterface::displayMenu() { char input; //while the user did not enter 3 (to exit the program) get the user's input do { cout << "Please select one of three options:" << endl; cout << "To enter a polynomial and have it displayed on the console, press 1" << endl; cout << "To enter add two polynomials together and display the result, press 2" << endl; cout << "To end the program, press 3" << endl; cin >> input; //if the user inputs 1, then they will be asked to enter the polynomial and it will be displayed back to them if (input == '1') { Polynomial polyInput; cout << "Please enter the polynomial" << endl; cin >> polyInput; cout << "Your polynomial: " << polyInput << endl; } //if the user enters 2, then they will be asked for two polynomials. Then the polynomials will be added together and will be displayed if (input == '2') { cout << "Please enter the first polynomial" << endl; Polynomial poly1 = getPoly(); cout << "Now enter the second polynomial" << endl; Polynomial poly2 = getPoly(); Polynomial finalPoly; finalPoly = poly1 + poly2; cout << "Your polynomial: " << finalPoly << endl; } if (input != '1' || input != '2' || input != '3') displayMenu(); } while (input != '3');
int main() { char input; cout << "========= R E S T A U R A N T S I N C U P E R T I N O ========="; listHead *restaurants = new listHead(hashSize); readFile(restaurants); restaurants->getHashPtr()->printHashTableSequence(); // Display menu displayMenu(); // Get user's input input = getUserInput(); // While the user does not want to quit... while (input != 'q') { // Call appropriate operation operationManager(restaurants, input); // Get user's input input = getUserInput(); } saveToFile(restaurants); cout << "\n======================== T H A N K Y O U ========================="; }
void Router::navigate() { system("CLS"); displayMenu(step); int param = _getch(); switch (param) { case 72: system("CLS"); step--; if (step < 0) if (parent != NULL) step = getMenuSize() + 1; else step = getMenuSize(); navigate(); break; case 80: system("CLS"); step++; if (step > getMenuSize() + (parent != NULL) ? 1 : 0) step = 0; navigate(); break; case 224: //system("CLS"); navigate(); break; case 13: setActive(&step); break; default: navigate(); } }
void Menu::menu(Oficina &oficina){ cout << "1 - Funções de adicionar" << endl; cout << "2 - Funções de remover" << endl; cout << "3 - Funções de display" << endl; cout << "4 - Funções de modificar" << endl; cout << "0 - Sair" << endl; int opcao; cin >> opcao; switch(opcao){ case 0: break; case 1: addMenu(oficina); break; case 2: removeMenu(oficina); break; case 3: displayMenu(oficina); break; case 4: modifyMenu(oficina); break; default: cout << "Opção inválida. Insira outra vez." << endl; menu(oficina); break; } }
int main(){ /* ####################### Init Game ####################### */ char menu = '0'; do{ menu = displayMenu(); if(menu == LAN){ configServer(); initPlayer(); } else if(menu == LOCAL){ initPlayer(); } printf("\n"); printf("Players were created"); printf("\n\n"); }while(menu!=EXIT); return 0; }
/************************** Main Method **************************/ int main(){ int choice; do{ choice = 0; displayMenu(); scanf("%d", &choice); switch(choice){ case 1: enterParameters(); break; case 2: checkHammingCode(); break; case 3: free(hamCode); exit(0); break; default: printf("Invalid selection\n\n"); //Clear the input stream in case of extraneous inputs. while ((choice = getchar()) != '\n' && choice != EOF); break; } }while(choice != 4); return 0; }
int main (void) { linkedList* memoryMap = new linkedList(); // instantiate linkedList memoryMap->create(); // create memory map (add Node) displayMenu(); // print menu to screen do { input = parseUser(); // make sure user is inputting number switch (input) { case 1: addProgram(memoryMap); // add program in MM break; case 2: killProgram(memoryMap); // kill progam in MM break; case 3: getFragments(memoryMap); // get fragements in MM break; case 4: memoryMap -> display(); // display MM break; } while (input != 1 && input != 2 && input != 3 && input != 4 && input != 5) { input = parseUser(); // make sure user is inputting numbers } } while (input == 1 || input == 2 || input == 3 || input == 4); // if input = 5 -> exit Program }
//virtual void EffectsListWidget::contextMenuEvent(QContextMenuEvent * event) { QTreeWidgetItem *item = itemAt(event->pos()); if (item && item->data(0, TypeRole) != EffectsList::EFFECT_FOLDER) { emit displayMenu(item, event->globalPos()); } }
// Function: // Input: // Output: // Description: char Menu::promptMenuChoice() { cin.clear(); displayMenu(); char choice; while(1) { string optionChoice = ""; cin >> optionChoice; if(optionChoice.length() > 1) { cout << "\nInvalid choice." << endl; cout << "\nEnter option: "; continue; } else { choice = optionChoice.at(0); if(isValidChoice(choice)) { return choice; } else { cout << "\nInvalid choice." << endl; cout << "\nEnter option: "; continue; } } } }
void MenuSystem::displayNextMenu(){ if((_curSubMenu + 1) <= _numSubMenus ){ _curSubMenu++; }else{ _curSubMenu = 1; } displayMenu(); }
int main(){ char allStar = '\0', regularMVP = '\0', worldMVP = '\0', goldGlove = '\0', silverSlug = '\0', homeRun = '\0', battingAve = '\0', gender = '\0'; int bonus = 0, num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, activityLevel = 0, menuChoice = 0, i = 0; double weight = 0, height = 0, age = 0, bmr = 0, calories = 0, result = 0; FILE *inputFile = NULL; //PROBLEM 1 inputFile = openInputFile(); /* gender = readCharacter(inputFile); age = readNumber(inputFile); weight = readNumber(inputFile); height = readNumber(inputFile); bmr = computeBMR(gender, weight, height, age); activityLevel = determineActivityLevel(); calories = computeCalories(bmr, activityLevel); printf("Calories needed per day are: %.0lf\n", calories); //PROBLEM 2 allStar = getBaseballAchievements("All-Star Game appearance"); bonus += determineBonus(allStar, 25000); regularMVP = getBaseballAchievements("Regular Season MVP"); bonus += determineBonus(regularMVP, 75000); worldMVP = getBaseballAchievements("World Series MVP"); bonus += determineBonus(worldMVP, 100000); goldGlove = getBaseballAchievements("Gold Glove award"); bonus += determineBonus(goldGlove, 50000); silverSlug = getBaseballAchievements("Silver Slugger award"); bonus += determineBonus(silverSlug, 35000); homeRun = getBaseballAchievements("Home run champ"); bonus += determineBonus(homeRun, 25000); battingAve = getBaseballAchievements("Batting average champ"); bonus += determineBonus(battingAve, 25000); printf("Total player bonus is %d\n", bonus); int i = 0;*/ //PROBLEM 3 num1 = readInteger(inputFile); num2 = readInteger(inputFile); num3 = readInteger(inputFile); num4 = readInteger(inputFile); num5 = readInteger(inputFile); while (i < 3){ menuChoice = displayMenu(); result = calculateResult(menuChoice, num1, num2, num3, num4, num5); displayResult(menuChoice, result); i++; } return 0; }
/*********************************************************************** Main ***********************************************************************/ void main(void) { DisableInterrupts; initializations(); EnableInterrupts; //enables external xirq after vSync IRQ vSyncFlag = 0; while((vSyncFlag != 1) & (hCnt == 0)) {} asm andcc #$BF ////////////////////////////////////////////////////////////// //; START OF CODE FOR Spring 2012 MINI-PROJECT ////////////////////////////////////////////////////////////// // Load/Display Spalsh Screen displaySplash(); for(;;) { // write code here (Insert Code down here because we need an infinite loop.) // Display Menu Screen displayMenu(selection); // Check for Menu Selection checkMenuInputs(joy0vert); // Use case statement to branch to appropriate selection. // Don't branch unless the user has triggered the 'select' button. if (select == 1) { select = 0; switch (selection) { // Sub Function // Menu: case 1: // Select Character selectCharacter(); break; case 2: // Select Field selectField(); break; case 3: // Start Match startMatch(); break; // the default case is '-1' if nothing has been selected default: break; } } // We don't need the watchdog timer, but I don't think it can hurt to feed it anyway. // The watchdog was disabled in the initialization code. _FEED_COP(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ }
int main(int argc, char** argv){ displayMenu(); srand(time(NULL)); while(1) { readInAndChoose(); } return 0; }
int main() { setlocale(LC_CTYPE, "Russian"); fflush(stdin); displayMenu(); return 0; }
/** * Show the menu */ void Menu::drawMenu() { displayMenu(); _menuActive = true; _msg4 = OPCODE_NONE; _msg3 = OPCODE_NONE; _menuSelected = false; _vm->setMouseClick(false); _multiTitle = false; }
void MenuSystem::selectSubMenu(){ _curMenu = _curSubMenu; _curOption = getMenuOption(_curMenu,1); Serial.print("Current Menu : "); Serial.println(_curMenu); Serial.print("Current option : "); Serial.println(_curOption); displayMenu(); }
int main(int agrc, char *argv[]) { system("clear"); displayMenu(); procMenu(); while(1) { sleep(1000); } }
// // Affiche le menu de sélection du plateau de jeu sur l'écran. // Si error vaut true, on affiche une erreur à la place du menu. // int displayGameBoardSelectionMenu() { char *choices[] = { "Plateau predefini", "Plateau depuis un fichier", "Plateau aleatoire", "Retour au menu principal" }; return displayMenu(choices, 4, "CHOIX DU PLATEAU", false); }
// // Affiche le menu principal du jeu sur l'écran. // Si error vaut true, on affiche une erreur à la place du menu. // int displayMainMenu() { char *choices[] = { "Partie solo", "Partie multijoueurs", "Classement", "Quitter" }; return displayMenu(choices, 4, "MENU PRINCIPAL", true); }
void* display_disk_info(void* nouse) { // THREAD_LOCK; displayDisk(); displayMenu(); displayDiskUsage(); printLogo(); createSuperBlockWindow(); // THREAD_UNLOCK; }
void initMainWindow() { createWindow(&mainWin, 100, 100, 0, 0); if (mainWin == NULL) { logPrint("Failed to create main window\n"); exit(-1); } werase(mainWin); keypad(mainWin, TRUE); resetMenuPos(); displayMenu(mainWin); }
void mainWelcome() { displayBounderay(BOUNDERAYTPYE); displayWelcome(); //displayExpense(TODAY,totalToday); displayExpense(MONTH,totalMonth); //displayExpense(YEAR,totalYear); //displayExpense(HISTORY,totalHistory); displayBounderay(BOUNDERAYTPYE); displayMenu(); return; }
void toListView::displayMenu(const QPoint &pos) { toTreeWidgetItem *item = itemAt(pos); if (!item) return; if (!Menu) { Menu = new QMenu(this); displayAct = Menu->addAction(tr("Display in editor...")); QMenu *just = new QMenu(tr("Alignment"), this); leftAct = just->addAction(tr("Left")); centerAct = just->addAction(tr("Center")); rightAct = just->addAction(tr("Right")); connect(just, SIGNAL(triggered(QAction *)), this, SLOT(menuCallback(QAction *))); Menu->addSeparator(); copyAct = Menu->addAction(tr("&Copy field")); // if (selectionMode() == Multi || selectionMode() == Extended) // { // copySelAct = Menu->addAction(tr("Copy selection")); // copyHeadAct = Menu->addAction(tr("Copy selection with header")); // } copyTransAct = Menu->addAction(tr("Copy transposed")); if (selectionMode() == Multi || selectionMode() == Extended) { Menu->addSeparator(); selectAllAct = Menu->addAction(tr("Select all")); } Menu->addSeparator(); exportAct = Menu->addAction(tr("Export to file...")); if (!Name.isEmpty()) { Menu->addSeparator(); editAct = Menu->addAction(tr("Edit SQL...")); } connect(Menu, SIGNAL(triggered(QAction *)), this, SLOT(menuCallback(QAction *))); addMenues(Menu); emit displayMenu(Menu); }
void mainMmi() { int action = -1; //char * dataPathToday; mmiNewConsume = 0; do { //displayWelcome(); action = mmiGetAction(); mmiHandleAction(action); if(mmiNewConsume > 0) { // dataPathToday = dataPathCrate(CONSUMETODAY); totalToday = dataCompute(mmiNewConsume, totalToday); dataStore(dataPathToday,totalToday); totalMonth = dataCompute(mmiNewConsume,totalMonth); dataStore(dataPathMonth,totalMonth); totalYear = dataCompute(mmiNewConsume,totalYear); dataStore(dataPathYear,totalYear); totalHistory = dataCompute(mmiNewConsume,totalHistory); dataStore(dataPathHistory,totalHistory); } if (action !=0) { //printf("Please any key to continue...\n"); // getchar(); // system("clear"); displayMenu(); } }while (action !=0); return; }
int main() { settings = new RTIMUSettings("RTIMULib"); bool mustExit = false; imu = NULL; newIMU(); // set up for calibration run imu->setCompassCalibrationMode(true); imu->setAccelCalibrationMode(true); magCal = new RTIMUMagCal(settings); magCal->magCalInit(); magMinMaxDone = false; accelCal = new RTIMUAccelCal(settings); accelCal->accelCalInit(); // set up console io struct termios ctty; tcgetattr(fileno(stdout), &ctty); ctty.c_lflag &= ~(ICANON); tcsetattr(fileno(stdout), TCSANOW, &ctty); // the main loop while (!mustExit) { displayMenu(); switch (tolower(getchar())) { case 'x' : mustExit = true; break; case 'm' : doMagMinMaxCal(); break; case 'e' : doMagEllipsoidCal(); break; case 'a' : doAccelCal(); break; } } printf("\nRTIMULibCal exiting\n"); return 0; }
int main(int argc, char *argv[]) { char option[10]; char saved[10]; int rc = 0; (void) argc; (void) argv; (void) rc; printf("%s\n", version_str); msgbuf = malloc(1500); if (NULL == msgbuf) { printf("memory allocation error - exiting\n"); return -1; } rc = mrpdclient_init(MRPD_PORT_DEFAULT); if (rc) { printf("init failed\n"); goto out; } saved[0]='\0'; while (!done) { displayMenu(); printf("Option to run? "); if (NULL == fgets(option, sizeof(option), stdin)) { done = 1; printf("\n"); continue; } option[strlen(option)-1] = '\0'; // remove assumed LF if ('\0' == option[0]) { // Repeat last cmd if nothing entered strncpy(option, saved, sizeof(option)); } rc = runMenuFunc(option); if (rc >= 0) { // Save last command if valid strncpy(saved, option, sizeof(option)); } } rc = mprdclient_close(); out: return rc; }