New to Turing. Click buttons wouldn't lead to the pages wanted
Author |
Message |
Deja_vu
|
Posted: Sun Jun 10, 2007 2:49 pm Post subject: New to Turing. Click buttons wouldn't lead to the pages wanted |
|
|
Hey guys! what's up???
We just started learning Turning program early this year and right now I am working on my last culminating activity in that class to finish off the year.
My project is to use Turning to control my zoo(model)'s temperature and heat according to the user's input info.
I started writting and this is what it looks like so far (don't laugh at me I know it looks really stupid to you guys)
*********************************************************************************************************************************
var x, y, button1, button2 : int
var intro1 : string := "Hi there, and welcome to the zoo. My name is Emily and I will be your host for the day."
var intro2 : string := "To start set up, simply click on the animal section you would like to change"
var intro3 : string := "For help&information, click help button"
var intro4 : string := "To quit, click quit button."
var font : int := Font.New ("Forte 0:12")
loop
% Creating the map of the zoo (home page)
drawfillbox (250, 250, 300, 155, red)
drawfillbox (320, 110, 420, 150, blue)
drawfillbox (500, 250, 440, 155, green)
drawfillbox (320, 260, 420, 310, yellow)
% labels and buttons (home page)
Font.Draw (intro1, 0, 380, font, 120)
Font.Draw (intro2, 0, 340, font, 120)
Font.Draw (intro3, 0, 50, font, 120)
Font.Draw (intro4, 0, 15, font, 120)
% creating help and quit button
drawfillbox (320, 69, 290, 45, 77)
drawfillbox (320, 34, 290, 10, 61)
end loop
var welcome1 : string := "Welcome to the graffiel section of the zoo"
var welcome2 : string := "Welcome to the lion section of the zoo"
var welcome3 : string := "Welcome to the zebra section of the zoo"
var welcome4 : string := "Welcome to the tiger section of the zoo"
loop
% selected animal section
buttonwait ("down", x, y, button1, button2)
locate (1, 1)
% giraf
if x >= 250 and x <= 300 and y >= 155 and y <= 250 then
cls
Font.Draw (welcome1, 10, 350, font, 107)
% lion
elsif x >= 500 and x <= 440 and y >= 250 and y <= 155 then
cls
Font.
% zebra
elsif x >= 320 and x <= 420 and y >= 110 and y <= 150 then
cls
% tiger
elsif x >= 320 and x <= 420 and y >= 260 and y <= 310 then
cls
else
put repeat (" ", 80)
end if
end loop
loop
buttonwait ("down", x, y, button1, button2)
locate (1, 1)
if x >= 320 and x <= 290 and y >= 69 and y <= 45 then
cls
put "Blue box has been selected."
elsif x >= 320 and x <= 290 and y >= 30 and y <= 10 then
cls
exit
else
put repeat (" ", 80)
end if
end loop
*******************************************************************************************************************************
When I tried to run the program everything seemed to be fine but when I clicked on any of the boxes nothing appeared and my other friend tried to help me but even when ours are the same it still wouldn't do anything.
can you guys see what exactly I did wrong and please point out the right way for me????
Also, is the temperature and heat sensor the only device I would use for my project????
thank you so so much |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Ultrahex
|
Posted: Sun Jun 10, 2007 3:18 pm Post subject: Re: New to Turing. Click buttons wouldn't lead to the pages wanted |
|
|
remember to use [code] tags or better yet [syntax] tags when posting code,
the problem is the first infinite loop will cause all the code below it to never be run, so after line 24, none of that code will be run because it will continue to be in that loop forever, there is no way to exit it. |
|
|
|
|
|
DifinityRJ
|
Posted: Sun Jun 10, 2007 3:34 pm Post subject: Re: New to Turing. Click buttons wouldn't lead to the pages wanted |
|
|
Deja_vu @ Mon Jun 11, 2007 8:49 am wrote:
We just started learning Turning program early this year and right now I am working on my last culminating activity in that class to finish off the year.
Correction : Turing, not Turning.
I wouldn't of post this if you put it once, because that might be a spelling error, but you said that more than once.
Deja_vu @ Mon Jun 11, 2007 8:49 am wrote: My project is to use Turning to control my zoo(model)'s temperature and heat according to the user's input info. |
|
|
|
|
|
Deja_vu
|
Posted: Sun Jun 10, 2007 8:11 pm Post subject: Re: New to Turing. Click buttons wouldn't lead to the pages wanted |
|
|
Ohh man thanks for pointing out I jus realized too I've been spelling it wrong the entire time.
My apologies |
|
|
|
|
|
Deja_vu
|
Posted: Sun Jun 10, 2007 8:17 pm Post subject: Re: New to Turing. Click buttons wouldn't lead to the pages wanted |
|
|
Ultrahex @ Sun Jun 10, 2007 3:18 pm wrote: remember to use [code] tags or better yet [syntax] tags when posting code,
the problem is the first infinite loop will cause all the code below it to never be run, so after line 24, none of that code will be run because it will continue to be in that loop forever, there is no way to exit it.
ok, so do I just keep everything in one infinite loop after line 24 then? |
|
|
|
|
|
Clayton
|
Posted: Sun Jun 10, 2007 8:53 pm Post subject: RE:New to Turing. Click buttons wouldn\'t lead to the pages wanted |
|
|
Yes. The idea is that you _never_ want a user to be able to exit from a program. If they should, run a virus, thus killing the host machine. This should serve as suitable punishment for exiting your precious program.
All sarcastic snides behind us, you should not ever have an infinite loop in a program when possible. You should always have some sort of exit condition in a loop. |
|
|
|
|
|
|
|