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

Username:   Password: 
 RegisterRegister   
 GUI CHECKBOXES "correct my code plz"
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nate




PostPosted: Thu Apr 03, 2003 10:19 pm   Post subject: GUI CHECKBOXES "correct my code plz"

Here is my code:
The first question works but the second does not. When you click on 1 of the boxes the previous option shows up behind the second questions option. **IF I SOUND CRAZY** Just try it out and you will understand. Also the response to the second question doesn't work.

COULD SOMEONE PLZ HELP ME FIX THESE PROBLEMS!!!

code:

import GUI in "%oot/lib/GUI" %Suts up Turing for GUI commands/code
View.Set ("graphics,nobuttonbar")
var questionfont : int := Font.New ("Arial:18:Underline")
var scorefont : int := Font.New ("Arial:14")
var score :int := 0
var winID : int := 0 %This windows ID
%#1 Your height (4 ranges)
var heightcb1, heightcb2, heightcb3, heightcb4 : int
var heightOptionS, heightOptionM, heightOptionL, heightOptionXL : boolean
%#2 Your weight (4 ranges)
var weightcb1, weightcb2, weightcb3, weightcb4 : int
var weightOption1, weightOption2, weightOption3, weightOption4 : boolean

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%Height Question
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


procedure checkboxheight1 (status : boolean) %Procedure for height checkboxes

    cls
    Font.Draw ("Sorry,You are to Small to play!!", 100, 200, questionfont, blue)
    delay (1000)
    Window.Close (winID + 1)

end checkboxheight1

procedure checkboxheight2 (status : boolean)

    cls
    Font.Draw ("A little short - 10 points", 20, 200, questionfont, blue)
    score -= 10
    delay (1000)

end checkboxheight2

procedure checkboxheight3 (status : boolean)

    cls
    Font.Draw ("Perfect height soldier!! + 10 points", 20, 200, questionfont, blue)
    score += 10
    delay (1000)

end checkboxheight3

procedure checkboxheight4 (status : boolean)

    cls
    Font.Draw ("Your a little to tall - 10 points", 20, 200, questionfont, blue)
    score -= 10
    delay (1000)

end checkboxheight4



colorback (grey)
cls
Font.Draw ("Question 1/10", 0, 380, scorefont, black)
Font.Draw ("What is your height range?", 20, 100, questionfont, red)


heightcb1 := GUI.CreateCheckBox (10, 50, "Under 5'", checkboxheight1)
heightcb2 := GUI.CreateCheckBox (150, 50, "5'-5'6''", checkboxheight2)
heightcb3 := GUI.CreateCheckBox (10, 10, "5'7'' - 6'2''", checkboxheight3)
heightcb4 := GUI.CreateCheckBox (150, 10, "Over 6'2''", checkboxheight4)

heightOptionS := GUI.GetCheckBox (heightcb1)
heightOptionM := GUI.GetCheckBox (heightcb2)
heightOptionL := GUI.GetCheckBox (heightcb3)
heightOptionXL := GUI.GetCheckBox (heightcb4)

loop
    exit when GUI.ProcessEvent
end loop

delay (3000)
cls


%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%End (Height) Question
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%Weight Question
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

procedure checkboxweight (status2 : boolean) %Procedure for weight checkboxes

    weightOption1 := GUI.GetCheckBox (weightcb1)
    weightOption2 := GUI.GetCheckBox (weightcb2)
    weightOption3 := GUI.GetCheckBox (weightcb3)
    weightOption4 := GUI.GetCheckBox (weightcb4)

    put ""
    cls

end checkboxweight


colorback (grey)
cls
Font.Draw ("Question 2/10", 0, 380, scorefont, black)
Font.Draw ("How heavy are you?", 20, 100, questionfont, red)


weightcb1 := GUI.CreateCheckBox (10, 50, "< 100 pounds", checkboxweight)
weightcb2 := GUI.CreateCheckBox (150, 50, "100 - 150 pounds", checkboxweight)
weightcb3 := GUI.CreateCheckBox (10, 10, "151 - 250 pounds", checkboxweight)
weightcb4 := GUI.CreateCheckBox (150, 10, "250+", checkboxweight)

weightOption1 := GUI.GetCheckBox (weightcb1)
weightOption2 := GUI.GetCheckBox (weightcb2)
weightOption3 := GUI.GetCheckBox (weightcb3)
weightOption4 := GUI.GetCheckBox (weightcb4)

loop
    exit when GUI.ProcessEvent
    exit when weightOption1 = true
    exit when weightOption2 = true
    exit when weightOption3 = true
    exit when weightOption4 = true
end loop

if weightOption1 = true then

    Font.Draw ("Your a needle!, start eating some food and maybe you can come back", 100, 200, questionfont, blue)
    GUI.Quit
    delay (1000)
    Window.Close (winID + 1)

elsif weightOption2 = true then

    Font.Draw ("You're a lightweight -10 points, but you can continue", 20, 200, questionfont, blue)
    score -= 10
    delay (1000)
    locate (23, 1)
    put "Your Score is ", score

elsif weightOption3 = true then

    Font.Draw ("Your just fine!! + 10", 20, 200, questionfont, blue)
    score += 10
    delay (1000)
    locate (23, 1)
    put "Your Score is ", score

elsif weightOption4 = true then

    Font.Draw ("What do you think this is!!! the camp for the fat!! - 10", 20, 200, questionfont, blue)
    score -= 10
    delay (1000)
    locate (23, 1)
    put "Your Score is ", score

end if




%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%End (Weight) Question
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


THANKS
-NATE
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Thu Apr 03, 2003 10:37 pm   Post subject: (No subject)

shouldnt this be in help?

Just moved - but dont look at me, I dont know much about GUI - Tony
Tony




PostPosted: Fri Apr 04, 2003 8:11 am   Post subject: (No subject)

alright... I took a closer look and I think that you exit when GUI.ProcessEvent is the problem.

you see, that loop will exit only when GUI.Quit is called, so your program never gets to second set of questions.

Now as I see it, you have two options here. Ether

a)
put both questions into the same loop linked to same GUI.ProcessEvent

which I'm not too sure about how to do... something with if statments and procedures Confused

or
b)

faking a goto line using loops (see loop tutorial) to skip over the first ProcessEvent and get to second set of questions


Also there might be something because you dont get rid of your boxes. It might make it better if you GUI.Dispose after the question was answered
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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: