
-----------------------------------
Jim
Fri Jan 11, 2008 8:54 am

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

-----------------------------------
Tony
Fri Jan 11, 2008 10:26 am

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

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.

-----------------------------------
Jim
Fri Jan 11, 2008 10:35 am

Re: Putting exit command
-----------------------------------
Ah, kk that works, thanks :). If I wanted to exit the whole run window would it be a different command?

thanks again :D

-----------------------------------
Tony
Fri Jan 11, 2008 10:55 am

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.

-----------------------------------
Sean
Fri Jan 11, 2008 12:50 pm

Re: Putting exit command
-----------------------------------
If you make a window from a variable then the Window.Close function would be used.

-----------------------------------
Carey
Fri Jan 11, 2008 12:56 pm

RE:Putting exit command
-----------------------------------
Or if you have 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
Fri Jan 11, 2008 1:01 pm

Re: Putting exit command
-----------------------------------
Cool thanks guys, appreciate everyones help :D

-----------------------------------
StealthArcher
Fri Jan 11, 2008 1:30 pm

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.

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.
