
-----------------------------------
mitko1994
Sat Jun 04, 2011 3:59 pm

Help need an if satement that will differ which button is pressed!!
-----------------------------------
hi everyone, i'm making a game with true and false questions. I want to make a score counter however i'm not sure how to use an if statement to tell the computer if the answer is true and the true button is pressed add 1 to the counter variable. I use GUIprocessevent but i just dont know how to put it in an if statement so that it recognizes which button is pressed.I know it could be that i add the counter to the procedure called by the button however both true and false buttons lead to the same procedure(the next question) I use regular buttons not full.


 thanks

-----------------------------------
Feltie
Sat Jun 04, 2011 4:12 pm

RE:Help need an if satement that will differ which button is pressed!!
-----------------------------------
can you link the prgoram please?

-----------------------------------
mitko1994
Sun Jun 05, 2011 8:14 am

Re: Help need an if satement that will differ which button is pressed!!
-----------------------------------
var counter:int:=0
var f1,t1:int


procedure Question1
    locate (2, 7)
    put "Question1"
    locate (8, 10)
    put "The CN Tower is located in Toronto."
    GUI.Show (t1)
    GUI.Show (f1)
    loop
        exit when GUI.ProcessEvent
    end loop
end Question1
procedure Question 2
 locate (2, 7)
    put "Question2"
    locate (8, 10)
    put "The capital city of Canada is Toronto."
    %GUI.Show (t2)
    %GUI.Show (f2)
    %loop
       % exit when GUI.ProcessEvent
    %end loop
end Question2

t1 := GUI.CreateButton (170, 200, 0, "True", Question2)
f1 := GUI.CreateButton (250, 200, 0, "False", Question2)


Please tell me how to write an if statement so that if "t1" is pressed, it adds 1 to "counter" or at least tell me how to express the if statement so that it's boolean.

Thanks

-----------------------------------
crossley7
Sun Jun 05, 2011 9:22 am

RE:Help need an if satement that will differ which button is pressed!!
-----------------------------------
If t1 = GUI.GetEventWigetID then

elsif f1 = GUI.GetEventWidgetID then

try those and look at the turing documentation for GUI commands.  I wrote a tron game earlier this year using it and completely self taught myself it using the documentation.

-----------------------------------
Tony
Sun Jun 05, 2011 12:14 pm

Re: Help need an if satement that will differ which button is pressed!!
-----------------------------------

  ...
  loop
    exit when GUI.ProcessEvent 
  end loop 
end Question1

That loop will never exit (that is, until you call GUI.Quit, which will disable all of your buttons).

-----------------------------------
mitko1994
Sun Jun 05, 2011 4:57 pm

Re: Help need an if satement that will differ which button is pressed!!
-----------------------------------
Works perfectly! thanks crossley7 :wink:  :lol:
