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

Username:   Password: 
 RegisterRegister   
 Quit button, now I need a Restart button......
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
HelloWorld




PostPosted: 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
Sponsor
sponsor
Delos




PostPosted: 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




PostPosted: 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.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: