I'm trying to create a status menu system with ncurses where the user is presented with three choices along a top row:
H S T
Each option selection prints various status over and over continuously. For ex. If the user chooses H, High status info is constantly being displayed.
If the user then pushes S, the H loop is broken and the S loop enters outputting system status info. And vice versa.
How can I go about this? I was thinking of using GOTO's but I know that's a no-no.
For ex. If I'm in H's while loop, the user pushes S, then that would break H's loop, the user would have to push S again, to enter S's loop.
Ahhhh so confused. (Actually there are more than 3 selections, but for simplicity, I only show 3. This is quickly going to become messy.)
Some pseudo-code below:
Thanks.
Code://e or E to exit program while ((ch = getch()) != 'e' || ch != 'E' ) { if (ch == 'H' || ch == 'h' ) { //infinite loop to constantly display H's status while (1){ getHighStatus function print high status if S is pressed, break, somehow enter S loop if T is pressed, break, somehow enter T loop } } else if (ch == 'S' || ch == 's' ) { while (1){ getSystemStatus function print system status if H pressed, break, somehow enter H loop if T prssed, break, somehow enter T loop } } else if (ch == 'T' || ch == 't' ) { while (1){ getTempStatus function print temp status if H pressed, break, somehow enter H loop if S pressed, break, somehow enter S loop } } else { print default message } }



2Likes
LinkBack URL
About LinkBacks


