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

Username:   Password: 
 RegisterRegister   
 cls doesnt work after end loop!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Bubka




PostPosted: Sat Nov 15, 2008 10:00 am   Post subject: cls doesnt work after end loop!!!

I have buttons in my code and a loop after them in order for them to work.
After end loop the cls does not clear the screen in order to allow the rest of the program to be displayed. I am new to Turing so I don't know what is wrong. Please help, thank you in advance.

code:

var question1Button1 : int := GUI.CreateButton (30, 50, 20, "BOIL", question1Choice1)
var question1Button2 : int := GUI.CreateButton (30, 70, 20, "FOIL", right1)
var question1Button3 : int := GUI.CreateButton (30, 90, 20, "BOOM", question1Choice2)
var question1Button4 : int := GUI.CreateButton (30, 110, 20, "SOIL", question1Choice3)

loop
    exit when GUI.ProcessEvent
end loop

delay (2000)
cls
Sponsor
Sponsor
Sponsor
sponsor
pavol




PostPosted: Sat Nov 15, 2008 11:10 am   Post subject: Re: cls doesnt work after end loop!!!

To clear GUI components off the screen you have to use the following code, not cls.
GUI.Dispose(objectName). For example, GUI.Dispose(question1Button1)
Bubka




PostPosted: Sat Nov 15, 2008 11:26 am   Post subject: Re: cls doesnt work after end loop!!!

I just tried that but it's still not working.
Once i click the button the message is displayed and it just remains there. I need it to remain there for a couple seconds or so and then continue with the rest of the code.

code:

var question1Button1 : int := GUI.CreateButton (30, 50, 20, "BOIL", question1Choice1)
var question1Button2 : int := GUI.CreateButton (30, 70, 20, "FOIL", right1)
var question1Button3 : int := GUI.CreateButton (30, 90, 20, "BOOM", question1Choice2)
var question1Button4 : int := GUI.CreateButton (30, 110, 20, "SOIL", question1Choice3)

loop
    exit when GUI.ProcessEvent
end loop

GUI.Dispose(question1Button1)
GUI.Dispose(question1Button2)
GUI.Dispose(question1Button3)
GUI.Dispose(question1Button4)

the above is what i typed based on your advice

after the screen clears, i want this displayed:
code:

drawfillbox (0, 0, 639, 399, blue)
drawfillbox (10, 10, 629, 389, white)
Font.Draw ("What is a polynomial", 20, 320, font2, green)
Font.Draw ("with only one term?", 20, 285, font2, green)


Please help if you can. Thanks
pavol




PostPosted: Sat Nov 15, 2008 12:09 pm   Post subject: RE:cls doesnt work after end loop!!!

Can you post the rest of your code please? and what seems to be the problem exactly? maybe its just me but i don't see what's going on. if you want things to pause you can use the delay() function. Just call
delay(time), time being in milliseconds.
CodeMonkey2000




PostPosted: Sat Nov 15, 2008 1:00 pm   Post subject: RE:cls doesnt work after end loop!!!

exit when GUI.ProcessEvent doesn't exit out of the loop. It runs that function, and it returns false.
Bubka




PostPosted: Sat Nov 15, 2008 1:45 pm   Post subject: Re: cls doesnt work after end loop!!!

here is the rest of my code.
basically the program is supposed to be a multiple choice math quiz.
After the first question ends, i have buttons as the choices to go with it. The problem begins after the first question is answered. It is supposed to clear the screen, then display the second question.

code:

%Declare GUI
import GUI

%Opening Page Graphics
drawfillbox (0, 0, 639, 399, blue)
drawfillbox (10, 10, 629, 389, white)
Pic.ScreenLoad ("math.bmp", 325, 40, picCopy)
var font1, font2 : int
font1 := Font.New ("serif:60:italic")
assert font1 > 0
font2 := Font.New ("serif:30:italic")
assert font2 > 0
Font.Draw ("Quiz", 30, 250, font1, red)
Font.Draw ("Time!!!", 50, 170, font1, red)

delay (2000)
cls

%Quiz question 1.
drawfillbox (0, 0, 639, 399, blue)
drawfillbox (10, 10, 629, 389, white)
Font.Draw ("What's the method", 20, 320, font2, green)
Font.Draw ("used for multiplying", 20, 280, font2, green)
Font.Draw ("binomials?", 20, 240, font2, green)
Pic.ScreenLoad ("question.bmp", 340, 20, picCopy)

%Create procedures for question 1.
procedure right1
    cls
    drawfillbox (0, 0, 639, 399, blue)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("You're Right!!!", 65, 200, font1, blue)
end right1

procedure question1Choice1
    cls
    drawfillbox (0, 0, 639, 399, red)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("Wrong!", 165, 200, font1, red)
    Music.PlayFile ("buzz.wav")
end question1Choice1

procedure question1Choice2
    cls
    drawfillbox (0, 0, 639, 399, red)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("Nope!", 165, 200, font1, red)
    Music.PlayFile ("buzz.wav")
end question1Choice2

procedure question1Choice3
    cls
    drawfillbox (0, 0, 639, 399, red)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("NOOOOOOOOOOO!", 65, 200, font1, red)
end question1Choice3

%Buttons for question 1 along with their parameters.
var question1Button1 : int := GUI.CreateButton (30, 50, 20, "BOIL", question1Choice1)
var question1Button2 : int := GUI.CreateButton (30, 70, 20, "FOIL", right1)
var question1Button3 : int := GUI.CreateButton (30, 90, 20, "BOOM", question1Choice2)
var question1Button4 : int := GUI.CreateButton (30, 110, 20, "SOIL", question1Choice3)

loop
    exit when GUI.ProcessEvent
end loop

GUI.Dispose (question1Button1)
GUI.Dispose (question1Button2)
GUI.Dispose (question1Button3)
GUI.Dispose (question1Button4)


%Quiz question 2.
drawfillbox (0, 0, 639, 399, blue)
drawfillbox (10, 10, 629, 389, white)
Font.Draw ("What is a polynomial", 20, 320, font2, green)
Font.Draw ("with only one term?", 20, 285, font2, green)


%Create procedures for question 2.
procedure right2
    cls
    drawfillbox (0, 0, 639, 399, blue)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("Nice!", 65, 200, font1, blue)
end right2

procedure question2Choice1
    cls
    drawfillbox (0, 0, 639, 399, red)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("Keep trying!", 165, 200, font1, red)
    Music.PlayFile ("buzz.wav")
end question2Choice1

procedure question2Choice2
    cls
    drawfillbox (0, 0, 639, 399, red)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("Nope!", 165, 200, font1, red)
    Music.PlayFile ("buzz.wav")
end question2Choice2

procedure question2Choice3
    cls
    drawfillbox (0, 0, 639, 399, red)
    drawfillbox (10, 10, 629, 389, white)
    Font.Draw ("NOOOOOOOOOOO!", 65, 200, font1, red)
    Music.PlayFile ("buzz.wav")
end question2Choice3

%Buttons for question 2 along with their parameters.
var question2Button1 : int := GUI.CreateButton (30, 50, 20, "Trinomial", question2Choice1)
var question2Button2 : int := GUI.CreateButton (30, 70, 20, "Constant", question2Choice2)
var question2Button3 : int := GUI.CreateButton (30, 90, 20, "Monomial", right2)
var question2Button4 : int := GUI.CreateButton (30, 110, 20, "Binomial", question2Choice3)
ecookman




PostPosted: Sat Nov 15, 2008 5:45 pm   Post subject: RE:cls doesnt work after end loop!!!

try putting it at the end of the lines

so where it says something like this

%Create procedures for question 1.
procedure right1
cls
drawfillbox (0, 0, 639, 399, blue)
drawfillbox (10, 10, 629, 389, white)
Font.Draw ("You're Right!!!", 65, 200, font1, blue)
end right1

procedure question1Choice1
cls


make it


%Create procedures for question 1.
procedure right1
cls
drawfillbox (0, 0, 639, 399, blue)
drawfillbox (10, 10, 629, 389, white)
Font.Draw ("You're Right!!!", 65, 200, font1, blue)
cls
end right1

procedure question1Choice1
Bubka




PostPosted: Sun Nov 16, 2008 9:50 am   Post subject: Re: cls doesnt work after end loop!!!

thanks that works for the clear screen however the rest of the code still doesnt display for some reason
Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Sun Nov 16, 2008 2:18 pm   Post subject: RE:cls doesnt work after end loop!!!

It doesn't work because when you use exit when GUI.ProcessEvent, that is always false so the loop never exits. You have to make it exit with another argument.

Maybe have a variable called answered and make that true when the question is answered.

Turing:

var answered : boolean := false
% YOUR CODE
% In your question, when it is answered, make the variable answered = true then the loop will exit and go to the next question.
loop
    exit when GUI.ProcessEvent or answered
end loop
Bubka




PostPosted: Mon Nov 17, 2008 9:39 am   Post subject: RE:cls doesnt work after end loop!!!

thanks andrew
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  [ 10 Posts ]
Jump to:   


Style:  
Search: