
-----------------------------------
Maverun
Mon Dec 22, 2014 4:18 am

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)



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Declare Variables
var choices, setting: int
var menu_setting : boolean

menu_setting := true
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Subprogram%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure settinggraphic

end settinggraphic

%Procedure Menu
procedure menu
    
        case choices of
            label 1 :
                put "You have selected new game"
                var menu_setting := false
                put "What your name?"
            label 2 :
                put "You have selected load game"
                put 50 * 5
            label 3 :
                put "You have selected setting"
                put "1-1920x1080"
                put "2-1600x900"
                put "3-1280x720"
                put "4-640x480"
                put "5-Exit"
                get setting
                case setting of
                    label 1 :
                        put "You have selected 1920x1080"
                        setscreen ("graphics:1920;1080")
                    label 2 :
                        put "You have selected 1600x900"
                        setscreen ("graphics:1600;900")
                    label 3 :
                        put "You have selected 1280x720"
                        setscreen ("graphics:1280;720")
                    label 4 :
                        put "You have selected 640x480"
                        setscreen ("graphics:640;480")
                    label 5 :
                        put "you have selected exit"
                        
                end case
            label :
                put "EH! uhh you didnt Make choies yet"
        end case
end menu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%Main Program%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
put "Enter your menu choice(1-new game, 2- load, 3 setting)"
get choices
cls
loop
    if menu_setting = true then
        menu
    elsif menu_setting = false then
        exit
    end if
end loop
        put "Program ended"




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. 


-----------------------------------
Insectoid
Mon Dec 22, 2014 5:31 pm

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).

-----------------------------------
Maverun
Tue Dec 23, 2014 1:42 am

Re: 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).

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 >.<

-----------------------------------
Insectoid
Tue Dec 23, 2014 9:35 am

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?

-----------------------------------
Maverun
Wed Dec 24, 2014 12:08 am

Re: Return back to menu in case
-----------------------------------
Oh, i am not so smart >.