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

Username:   Password: 
 RegisterRegister   
 traffic light gui.... HELP
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
holy.ballsack




PostPosted: Thu Jan 07, 2010 9:23 am   Post subject: traffic light gui.... HELP

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
holy.ballsack




PostPosted: Thu Jan 07, 2010 9:26 am   Post subject: RE:traffic light gui.... HELP

we are successful in making the the start button start....but we cannot get the stop and exit button working... we also need help on making the traffic lights on the right to work.... when we click start.... it should start as traffic lights

this program has to interface with the breadboard circuit peripherals which we are successful in



setscreen ("graphics")
procedure gui
%Writes the text for button 1.
locatexy (110, 325)
put "ON"
%Writes the text for button 2.
locatexy (110, 200)
put "OFF"
%Writes the text for button 3.
locatexy (110, 75)
put "EXIT"
%Draws the three boxes.
drawbox (50, 275, 175, 375, red)
drawbox (50, 150, 175, 250, red)
drawbox (50, 25, 175, 125, red)
%Draws the circle representing the LED.
drawoval (450, 300, 25, 25, red)
drawoval (450, 225, 25, 25, yellow)
drawoval (450, 150, 25, 25, green)
end gui

var x, y, button, stop : int
stop:=0
gui %Calls the procedure gui.
loop
mousewhere (x, y, button)
if button = 1 and 50 <= x and x <= 175 and 275 <= y and y <= 375 then
loop
parallelput (4) /* Red */
delay (3000)
parallelput (1) /* green */
delay (3000)
parallelput (2) /* Yellow */
delay (2000)
exit when stop =1
end loop
elsif button = 1 and 50 <= x and x <= 175 and 150 <= y and y <= 250 then
stop:=1
end if
%If button 3 is clicked, exits the program
exit when button = 1 and 50 <= x and x <= 175 and 25 <= y and y <= 125
end loop
qmanjr5




PostPosted: Thu Jan 07, 2010 9:42 am   Post subject: RE:traffic light gui.... HELP

Firstly, I can't help you.
Secondly, don't doublepost.
Thirdly, use the format provided.
Zren




PostPosted: Thu Jan 07, 2010 5:49 pm   Post subject: RE:traffic light gui.... HELP

Well your no help qmanjr5.

Your program already Finishes when you click Exit, it just does close the window. Look up Window.Open and Window.Close in the Turing Docs if your really nit picky.
http://compsci.ca/holtsoft/doc/

Now for the actual problem. Well lets run through whats actually happening.

Draw Everything.
Quickly see if you mouse is clicked on one of the start button.
If so ->
Send Red Light.
Wait 3 seconds
Send Green Light.
Wait 3 seconds.
Send Yellow Light.
Wait 2 seconds.
~Start repeating...
Send Red Light.
Wait 3 seconds
...

You are not changing the exit variable within that loop. Sure we could add the if statement that checks for exiting into that loop, but it would only check every 8 seconds.

Instead of wanting to do this:
Send Red Light.
Wait 3 seconds

We want to do something like this:
Send Red Light
Has OFF been clicked?
Is it time to change the light?
Has OFF been clicked?
Is it time to change the light?
Yes it is. Okay, make it green.
Has OFF been clicked?
Is it time to change the light?

Can you think of a way to achieve this?
registration




PostPosted: Thu Jan 07, 2010 7:13 pm   Post subject: Re: RE:traffic light gui.... HELP

qmanjr5 @ Thu Jan 07, 2010 9:42 am wrote:
Firstly, I can't help you.
Secondly, don't doublepost.
Thirdly, use the format provided.

1. Then don't post.
2. It's called a forum glitch so he had to double post.
3. He doesn't have to if he doesn't want to.
4. Learn English.

@ OP the correct answer is posted above so I won't repeat.
qmanjr5




PostPosted: Mon Jan 11, 2010 11:16 pm   Post subject: RE:traffic light gui.... HELP

Erm, are you telling ME to learn English?

1. I was just informing him that he could disregard my post.
2. He could've delete original post, and made new thread.
3. If he doesn't want to, he could've delete the whole format...
4. I can speak English quite well, thank you very much.
Ktomislav




PostPosted: Tue Jan 12, 2010 10:13 am   Post subject: Re: traffic light gui.... HELP

It actually closes the window, but only if you run a stand alone exe file.
Turing lets you see the final output of your program to help you debug it.
mirhagk




PostPosted: Tue Jan 12, 2010 1:35 pm   Post subject: RE:traffic light gui.... HELP

i always like to start my program with
Turing:

var win:=Window.Open("nobuttonbar")

and end my program with
Turing:

because it takes too long to keep running, checking to see if it works, then clicking x and editing and doing it all over.

I usually have
Turing:

var win:=Window.Open("nobuttonbar")
var keys:=array char of boolean
%all my variablse and procedures
loop
exit when keys(KEY_ESC)
%all my code
end loop
Window.Close(win)

that way i can close the program at any point by simply pressing ESC.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: