Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Exiting A Procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Abdiwahab




PostPosted: Tue Jan 15, 2008 6:44 pm   Post subject: 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 Shocked Is their any way to full exit a procedure?
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Tue Jan 15, 2008 7:11 pm   Post subject: RE:Exiting A Procedure

recursion...

code:

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




PostPosted: Tue Jan 15, 2008 7:34 pm   Post subject: 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




PostPosted: Tue Jan 15, 2008 9:54 pm   Post subject: 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




PostPosted: Tue Jan 15, 2008 10:23 pm   Post subject: RE:Exiting A Procedure

Look into return
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: