Computer Science Canada using buttons |
Author: | adams [ Mon May 16, 2005 7:32 pm ] |
Post subject: | using buttons |
i need help with this program. It creates 6 buttons for a trivia question.(i will be doing multiple questions) I want to show them one at a time For question 1 when any of the buttons are pressed the screen clears and shows either right or wrong (which is what I want). But it does not go to the next question, the screen just stays blank. How can i make it go to question 2 and then the 3rd etc...(is there a "go to" command of some type?? HELP!!! note : I called the buttons in the second question because i couldn't make them numbers. correct me on anything else if you wish. [/code] end Brazil procedure Italy cls Font.Draw ("Wrong", 0, 50, font2, black) delay (1250) cls end Italy procedure Germany cls Font.Draw ("Wrong", 0, 50, font2, black) delay (1250) cls end Germany %buttons below (location and what will be displayed on the button) var button1 : int := GUI.CreateButton (100, 100, 20, "France", France) var button2 : int := GUI.CreateButton (100, 130, 20, "England", England) var button3 : int := GUI.CreateButton (100, 160, 20, "Spain", Spain) var button4 : int := GUI.CreateButton (100, 190, 20, "Brazil", Brazil) var button5 : int := GUI.CreateButton (100, 220, 20, "Italy", Italy) var button6 : int := GUI.CreateButton (100, 250, 20, "Germany", Germany) loop exit when GUI.ProcessEvent end loop %**********question 2********** Font.Draw ("When did the sport become recognized?", 0, 375, font1, black) %below displays what will appear after a button is selected procedure example1 cls Font.Draw ("Wrong", 0, 50, font2, black) delay (1250) cls end example1 procedure example2 Font.Draw ("Wrong", 0, 50, font1, black) delay (1250) cls end example2 procedure example3 cls Font.Draw ("Wrong", 0, 50, font2, black) delay (1250) cls end example3 procedure example4 cls Font.Draw ("Wrong", 0, 50, font2, black) delay (1250) cls end example4 procedure example5 cls Font.Draw ("Right", 0, 50, font2, black) delay (1250) cls end example5 procedure example6 cls Font.Draw ("Wrong", 0, 50, font2, black) delay (1250) cls end example6 %buttons below (location and what will be displayed on the button) var button7 : int := GUI.CreateButton (100, 100, 20, "1894", example1) var button8 : int := GUI.CreateButton (100, 130, 20, "1855", example2) var button9 : int := GUI.CreateButton (100, 160, 20, "1848", example3) var button10 : int := GUI.CreateButton (100, 190, 20, "1877", example4) var button11 : int := GUI.CreateButton (100, 220, 20, "1863", example5) var button12 : int := GUI.CreateButton (100, 250, 20, "1886", example6) loop exit when GUI.ProcessEvent end loop |
Author: | Delos [ Mon May 16, 2005 8:19 pm ] |
Post subject: | |
1) Hello. Welcome. 2) Tags are not that difficult to use. If you don't want to manually type out the []'s, the simply highlight your chosen text and click the "Code" button in the Post options. 3) Please don't use titles such as "I need help", or "Please help". This helps no one. If we do not know what the thread is about we might not feel like opening it. In addition, there is a Sticky dedicated to this warning, as well as a post on the Main Page. 4) Change your thread title, fix your post, and I'm sure people will drop by to give you tips. |
Author: | sockoo [ Mon May 16, 2005 8:55 pm ] | ||
Post subject: | |||
Ok if i understand correctly here's is what you have to do .. and assuming you know how to use procedures cause u'v already used them put each button in its own procedure .. and when you want that button to be called .. well call it for example
|
Author: | sockoo [ Mon May 16, 2005 9:00 pm ] | ||
Post subject: | |||
Assuming you wanna keep going back to those same buttons .. i modified ur code so it would do so |
Author: | sockoo [ Tue May 17, 2005 12:08 pm ] | ||
Post subject: | |||
My question for you tho .. is why have .. 6 different procedures with almost the same thing in them why not just have 2 ? .. (one for right and one for wrong .. for example: )
|
Author: | adams [ Tue May 17, 2005 8:12 pm ] |
Post subject: | |
thank you sockoo. im new to making buttons. I just looked at the turing reference thing and took it from there |
Author: | adams [ Wed May 18, 2005 5:54 pm ] | ||
Post subject: | |||
ok i appreciate the help but i still havent had my question answered. all i want to do is get from question 1 to question 2 and continue the trivia. i think the problem is with the "exit when" in the loop. or i need a go to command of some type (if there is one).
|
Author: | sockoo [ Thu May 19, 2005 8:54 am ] | ||
Post subject: | |||
i fixed up ur code it goes over to the next question now all you need to do is fix up ur buttons soo after it gets it wrong on the second question it re shows .. those same buttons not the ones from before .. i'd help you out .. but class is over so0o i'll have a look at it when i get home if i have the time .. gl!
|
Author: | adams [ Thu May 19, 2005 10:51 am ] |
Post subject: | |
sockoo can you please put comments to help me to understand what all the "forward proc" and "body proc" etc... do? |
Author: | adams [ Thu May 19, 2005 4:14 pm ] |
Post subject: | |
i found a little problem. When i click the right answer (1863) in the second question it says "wrong". If you click and hold "1855" you see "England" which is the right answer for the first question. So "1855" ends up being the right answer in the second question. I need the program to completely forget the last question. |
Author: | sockoo [ Thu May 19, 2005 5:13 pm ] |
Post subject: | |
adams wrote: sockoo can you please put comments to help me to understand what all the "forward proc" and "body proc" etc... do?
all those are doing is calling the procedure at the start of ur program .. not giving u the error " Bla Bla has no been declared .. " and i know that error is that .. i told you it was there .. its your program .. im not going to program the whole thing for you .. even tho that'd be really nice of me .. , try n figure it out ur self .. what are you going to learn with me doing if for you ? |
Author: | adams [ Fri May 20, 2005 10:01 am ] |
Post subject: | |
ok i figured out what "body pro" and "forward proc" do. But i dont know how to fix my buttons part. If you click and hold on a button and then take the mouse off it shows the name of the button from the last question. |
Author: | adams [ Fri May 20, 2005 11:09 am ] | ||
Post subject: | |||
I think I need to use GUI.Dispose but I don't know the right spot to put it in. When I put it in a place that isn't in the same "body proc" that contains the buttons I want to delete i get 'button 1,2,3,4,5,6' not declared. But if I put it in the same "body proc" that contain the buttons I want to delete the buttons will not show. heres what I have so far.
|
Author: | sockoo [ Fri May 20, 2005 2:52 pm ] | ||
Post subject: | |||
what you will want to do is put lets say .. buttons 1- 7 ? ... or whatever buttons you use for ur first question .. put the those dispose buttons in a procedure then before you go to draw new buttons .. (in proc b2 i beleive) write the name of the procedure to dispose of the buttons from 1-7 .. here's an example of what i mean
|
Author: | adams [ Fri May 20, 2005 9:18 pm ] | ||
Post subject: | |||
ok i do that but it says that button1 has not been declared. And when i put all of them in their own GUI.Dispose they are all said not to be declared.
|