Computer Science Canada Return back to menu in case |
Author: | Maverun [ Mon Dec 22, 2014 4:18 am ] | ||
Post subject: | Return back to menu in case | ||
What is it you are trying to achieve? I am trying to get back to menu for example in menu, there are 3 case to pick, and i pick case 2 for example, now i want to go back to where i can see 3 choices again, but how? What is the problem you are having? At this moment, i am seeing loop Describe what you have tried to solve this problem i try add loops and exit when conditions reached, and i try if statement as well in this code, I try go to case 3, which is setting and now i want to exit setting and return to menu but ended up with loop (without loop, program would have ended) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1 i believe OFF-TOPIC: i have quick question about setscreen, if i make screen bigger, text or object would be mess up because of default, is there way to fix it? I haven't done check it but i have feeling it could happen I am sorry for my English. |
Author: | Insectoid [ Mon Dec 22, 2014 5:31 pm ] |
Post subject: | RE:Return back to menu in case |
Your menu is just a procedure. You call it inside a loop. When a procedure finishes, it 'goes out of scope', which means that the code continues with the next line after you called the procedure. Your call to the procedure 'menu' is inside a loop. When 'menu' finishes, the loop will execute whatever comes next. In your case, that's nothing. It just starts the loop over again (which leads to 'menu' executing again, or not). You need to change your loop so that whatever happens after your call to 'menu' is what you want (the previous menu). |
Author: | Maverun [ Tue Dec 23, 2014 1:42 am ] |
Post subject: | Re: RE:Return back to menu in case |
Insectoid @ Mon Dec 22, 2014 5:31 pm wrote: Your menu is just a procedure. You call it inside a loop. When a procedure finishes, it 'goes out of scope', which means that the code continues with the next line after you called the procedure. Your call to the procedure 'menu' is inside a loop. When 'menu' finishes, the loop will execute whatever comes next. In your case, that's nothing. It just starts the loop over again (which leads to 'menu' executing again, or not). You need to change your loop so that whatever happens after your call to 'menu' is what you want (the previous menu).
I am sorry, i may not understand what you are trying to say here, are you saying instead of adding loop outside but add loop inside? Just to make it clear as i can, for example, there are 1 case of 3 sub, so i am in one of them, now i want to exit that case to where i can see case again to make choices again. If i add loop, i will see same case i did picked before again, i do not want to see that, i want to see other case options. I am sorry for trouble, i am trying to figure it out >.< |
Author: | Insectoid [ Tue Dec 23, 2014 9:35 am ] |
Post subject: | RE:Return back to menu in case |
You don't need to add or remove any loops. Just change the one you already have. You're like 99% of the way there. You literally just need to move 2 lines of code that you've already written to a different spot. You want to make something (the main menu) happen over and over again. How do you do that? |
Author: | Maverun [ Wed Dec 24, 2014 12:08 am ] | ||
Post subject: | Re: Return back to menu in case | ||
Oh, i am not so smart >.<, thank you, you mean to move get variable inside procedure, because, once i done it loop, program will think i still want 3, so therefore add get statement inside in order to make loop go back to it. Like this
Thank you for your help. |