
-----------------------------------
Abdiwahab
Tue Jan 15, 2008 6:44 pm

Exiting A Procedure
-----------------------------------
I have a game running in a loop in one procedure and if the user clicks on a box it goes to procedure mainMenu...but the loop is still running and all the mainMenu does is sit there like an image :shock:   Is their any way to full exit a procedure?

-----------------------------------
TokenHerbz
Tue Jan 15, 2008 7:11 pm

RE:Exiting A Procedure
-----------------------------------
recursion...


proc menu
     if speed selected then
           call speed_adjust proc
     elsif username change then
           call username proc
      end if

      if menu isnt exited then
          menu %% recalls the menu
     elsif menu is exited then
          back to where you go
     end if
end menu

loop 
    game stuff here
    if key = menu then
        call menu proc
    end if
end loop


thats just theory, seems logical, i would try it!
"Edit for code tags"

-----------------------------------
syntax_error
Tue Jan 15, 2008 7:34 pm

Re: Exiting A Procedure
-----------------------------------
although TokenHerbz idea  maybe better and more sophisticated 
but how bout you have a cls before each proc starts and a cls before you draw ur menu
simple no?

-----------------------------------
ericfourfour
Tue Jan 15, 2008 9:54 pm

RE:Exiting A Procedure
-----------------------------------
That is a poor example of where to use recursion. A situation like this just requires planning of how your are going to make your loop. Pay attention to scope and where your exit statements are. If you are using Turing's GUI make sure you are using the ProcessEvent funtion and Quit procedure correctly.

Do not use recursion in a situation like this. It only decreases the robustness of your program.

-----------------------------------
Clayton
Tue Jan 15, 2008 10:23 pm

RE:Exiting A Procedure
-----------------------------------
Look into return
