Quit button, now I need a Restart button......
Author |
Message |
HelloWorld
|
Posted: Sun Nov 07, 2004 9:07 pm Post subject: Quit button, now I need a Restart button...... |
|
|
(Yes, I am a newbe).
Hello world, I made a program and I now put a quit button at the bottom of the program.
And I would also like to put a restart button right beside it, so when the user clicks the 'RESTART' button, the program will loop to the beginning and start all over.
The code for the quit button is as is below:
code: |
import GUI in "%oot/support/lib/GUI"
procedure QuitPressed
GUI.Quit
end QuitPressed
var quitButton := GUI.CreateButton (500, 10, 100, "Quit", QuitPressed)
loop
exit when GUI.ProcessEvent
end loop
var quitMessage := GUI.CreateLabelFull (0, 0, "Thank You For Using This Program!",
maxx, maxy - 135, GUI.CENTER + GUI.MIDDLE, 0)
|
I would like to have a restart button that looks the same as this. I would really appreciate any help at all. Thank you in advance. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Delos
|
Posted: Sun Nov 07, 2004 10:21 pm Post subject: (No subject) |
|
|
Hmm...let's see...
You could put your loop w/ the QUI.ProcessEvent in another loop. The quit button would signal two flags, one to exit the inner loop, one to exit the outer loop.
The reset button would only signal exit from the inner loop, which you loop you back to the beginning of the outer loop.
Here you can reset all necassary variables (including GUI.ResetQuit).
I'm not sure if that would work...it might mean that you wouldn't actually use "GUI.Quit"...but that's not a problem if it gets things done.
BTW, I'm sure there are easier ways to do this, I'm just throwing stuff off the top of my head (And I just washed my hair so there won't be any dandruff...don't worry). |
|
|
|
|
|
myob
|
Posted: Mon Nov 08, 2004 7:04 am Post subject: (No subject) |
|
|
iirc, gui.quit just exit the gui loop, so if he gui.quit, then the restart button probably gonna be also disabled. im not sure how double loop gonna work neither, considering if u declare gui again in inner loop it might not work. i think one way to get around this is when pressing quit button, u dont gui.quit. lets say for a program, i click on quit button to end the program, i can do gui.quit then window.close or i can just do window.close and ignore the gui.quit since the program ended anyways. in this case, all you want is to display the "Thanks for using the program" message, there is no need to gui.quit anyways. correct me if im wrong, havent touch turing in like 4 months. |
|
|
|
|
|
|
|