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

Username:   Password: 
 RegisterRegister   
 Putting exit command
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jim




PostPosted: Fri Jan 11, 2008 8:54 am   Post subject: Putting exit command

Currently working on an intro screen for a game but ive run into a problem with my quit button. I dont exactly know how to add an exit condition or exit command into it. My Being and Quit buttons are both procedures, would be great if i could possibly get some feed back on how to put the exit into the quit procedure.

Thanks.

Current Program

import GUI
var font1 : int
font1 := Font.New ("comicsans:14")
Font.Draw ("A Caves and Lizards Production", 175, 175, font1, red)


var mypic : int := Pic.FileNew ("LZRD.bmp")
Pic.Draw (mypic, maxx div 2.5, maxy div 2, 0)
Pic.Free (mypic)

procedure Begin
locate (1, 1)
put "You Have Selected To Play"
end Begin


procedure Quit
locate (1, 1)
put "Bye!"
end Quit

var button2 : int := GUI.CreateButton (25, 50, 0, "Play", Begin)
var button1 : int := GUI.CreateButton (25, 25, 0, "Exit", Quit)



loop
exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Jan 11, 2008 10:26 am   Post subject: RE:Putting exit command

that is because your quit procedure doesn't do anything, it just says it's "bye", but it has no effect on your
code:

loop
  exit when GUI.ProcessEvent
end loop

which will just keep on running until GUI.ProcessEvent return true. Calling GUI.Quit at any point will do that.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Jim




PostPosted: Fri Jan 11, 2008 10:35 am   Post subject: Re: Putting exit command

Ah, kk that works, thanks Smile. If I wanted to exit the whole run window would it be a different command?

thanks again Very Happy
Tony




PostPosted: Fri Jan 11, 2008 10:55 am   Post subject: RE:Putting exit command

well GUI.Quit just makes you exit out of the loop. If you have some code after it, that will be executed.

I think Turing's quit might quit the entire application. I don't remember if the run window actually closes at completion.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sean




PostPosted: Fri Jan 11, 2008 12:50 pm   Post subject: Re: Putting exit command

If you make a window from a variable then the Window.Close function would be used.
Carey




PostPosted: Fri Jan 11, 2008 12:56 pm   Post subject: RE:Putting exit command

Or if you have
code:
return
outside of a procedure it will automatically finish your program. You can then set it to immediately close the run window when the program finishes when creating an exe
Jim




PostPosted: Fri Jan 11, 2008 1:01 pm   Post subject: Re: Putting exit command

Cool thanks guys, appreciate everyones help Very Happy
StealthArcher




PostPosted: Fri Jan 11, 2008 1:30 pm   Post subject: Re: Putting exit command

Tony @ Fri Jan 11, 2008 9:55 am wrote:
well GUI.Quit just makes you exit out of the loop. If you have some code after it, that will be executed.

I think Turing's quit might quit the entire application. I don't remember if the run window actually closes at completion.


As for the quit command, don't use it, it will always cause a warning window to come up stating error gibberish at the user, even after compilation.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: