word wait_dialog() { word key,mx,my,ev; for(;;) { xor_command(); ev=get_event(&key,&mx,&my); xor_command(); if (ev&EV_KEY) { if (key==KEY_ESC) return ERRM_INTERRUPTED; key_command(key); if ( (key==KEY_RETURN) || (key==KEY_ENTER) ) return 0; } } return ev; }
/* * void execute_commands() * * Processes commands until the QUIT command is entered * */ void execute_commands() { char buffer[MAX_INPUT_STRING]; int num_chars = 0; while ( TRUE ) { printf( PROMPT ); scanf("%s", buffer); num_chars = strlen(buffer); if ( is_valid_number( buffer ) ) { push( atoi(buffer) ); continue; } if ( num_chars > 1 ) { printf( BAD_INPUT_MSG ); continue; } if ( tolower( buffer[0] ) == QUIT ) return; /* Remove the TODO_MSG as you implement and test commands */ switch( tolower( buffer[0] ) ){ case ADD: add_command(); break; case SUB: sub_command(); break; case MULT: mult_command(); break; case DIV: div_command(); break; case MOD: mod_command(); break; case AND: and_command(); break; case OR: or_command(); break; case XOR: xor_command(); break; case NOT: not_command(); break; case FACTORIAL: factorial_command(); break; case TOGGLE_HEX: toggle_hex(); break; case TOGGLE_BUG: toggle_bug(); break; case PRINT_STACK: print_stack(); break; case PRINT_TOP: print_top(); break; case CLEAR: clear_command(); break; case EXCHANGE: exchange_command(); break; case POP: pop(); break; case HELP: help_command(); break; default: printf( BAD_INPUT_MSG ); } } }