
-----------------------------------
holy.ballsack
Thu Jan 07, 2010 9:23 am

traffic light gui.... HELP
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using


-----------------------------------
holy.ballsack
Thu Jan 07, 2010 9:26 am

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 
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
Thu Jan 07, 2010 7:13 pm

Re: RE:traffic light gui.... HELP
-----------------------------------
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
Mon Jan 11, 2010 11:16 pm

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
Tue Jan 12, 2010 10:13 am

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
Tue Jan 12, 2010 1:35 pm

RE:traffic light gui.... HELP
-----------------------------------
i always like to start my program with

var win:=Window.Open("nobuttonbar")

and end my program with 

Window.Close(win)

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

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.
