Discussion:
Make a flashing light
(too old to reply)
Rene
2008-05-28 19:01:31 UTC
Permalink
Hello to all,

I am doing a course in C++ and we use BC6++. Now we had to make a class to
paint a traffic light and a program that asks this class to do so. It also
should have a button that makes the light go green -> yellow -> red ->
green -> asf... , one step with each press. No problem so far.
However, I would like to add a feature to make it a bit more luxurious. In
my country, when traffic is low (that means, almost never :-( ), the light
will only show a flashing yellow. I would like to add a button to put my
light into that modus. Is there a way to do this without being "stuck" in
that function, I mean, something in the background that will continu to turn
on and off the yellow light without having to use wait loops?

Thank You very much in advance!
Yours sincerely,
Rene

P.S. I do not ask for a full solution, I would already be very happy if You
might give me some keywords what to look for on the web.
Bruce Salzman
2008-05-28 19:17:35 UTC
Permalink
Post by Rene
Hello to all,
I am doing a course in C++ and we use BC6++. Now we had to make a class to
paint a traffic light and a program that asks this class to do so. It also
should have a button that makes the light go green -> yellow -> red ->
green -> asf... , one step with each press. No problem so far.
However, I would like to add a feature to make it a bit more luxurious. In
my country, when traffic is low (that means, almost never :-( ), the light
will only show a flashing yellow. I would like to add a button to put my
light into that modus. Is there a way to do this without being "stuck" in
that function, I mean, something in the background that will continu to turn
on and off the yellow light without having to use wait loops?
Thank You very much in advance!
Yours sincerely,
Rene
P.S. I do not ask for a full solution, I would already be very happy if You
might give me some keywords what to look for on the web.
Use the timer component.
--
Bruce
Rene
2008-06-02 17:04:42 UTC
Permalink
Post by Bruce Salzman
Post by Rene
Hello to all,
I am doing a course in C++ and we use BC6++. Now we had to make a class
to paint a traffic light and a program that asks this class to do so. It
also should have a button that makes the light go green -> yellow ->
red -> green -> asf... , one step with each press. No problem so far.
However, I would like to add a feature to make it a bit more luxurious.
In my country, when traffic is low (that means, almost never :-( ), the
light will only show a flashing yellow. I would like to add a button to
put my light into that modus. Is there a way to do this without being
"stuck" in that function, I mean, something in the background that will
continu to turn on and off the yellow light without having to use wait
loops?
Thank You very much in advance!
Yours sincerely,
Rene
P.S. I do not ask for a full solution, I would already be very happy if
You might give me some keywords what to look for on the web.
Use the timer component.
Hello Bruce,

I am sorry to have not replied a bit sooner, I have been terribly busy with
other - unfortunately much less interesting - courses. I have read Your
reply a couple of days ago and have looked up some more info about it. Using
that component is not yet possible for me because there are too many things
that are being talked about I do not understand yet, so I have handed in my
traffic light without the flashing function. Nevertheless, when I have a bit
more time on my hands I am going to look into it a bit deeper.

Thanks again!
Yours sincerely,
Rene

P.S. You helped me some time ago as well, I can tell You I am making good
progress and still like this language and programming environment very well.
Rene
2008-06-05 12:41:14 UTC
Permalink
Post by Bruce Salzman
Post by Rene
Hello to all,
I am doing a course in C++ and we use BC6++. Now we had to make a class
to paint a traffic light and a program that asks this class to do so. It
also should have a button that makes the light go green -> yellow ->
red -> green -> asf... , one step with each press. No problem so far.
However, I would like to add a feature to make it a bit more luxurious.
In my country, when traffic is low (that means, almost never :-( ), the
light will only show a flashing yellow. I would like to add a button to
put my light into that modus. Is there a way to do this without being
"stuck" in that function, I mean, something in the background that will
continu to turn on and off the yellow light without having to use wait
loops?
Thank You very much in advance!
Yours sincerely,
Rene
P.S. I do not ask for a full solution, I would already be very happy if
You might give me some keywords what to look for on the web.
Use the timer component.
Hello again Bruce,

I told a friend I met last tuesday about our conversation and he said "Oh,
using the timer is very easy, just drop it onto your form". I had no idea it
was that easy, I read a lot of things about the timer component after
reading Your tip but did not know that the timer was somewhere in the bar on
top of the screen, in fact, it had not even come to my mind that it might be
there (else I would have looked for it), as far as I knew, in that bar were
only things one might draw on the form like an editbox, labels and so forth,
I thought using the timer required a lot of source code but in fact it is
just as easy as placing a button on a form. When I have some more time I am
going to thoroughly explore all the things in those bars.
My traffic light is already up and running in it's "out of service" mode,
makes me very happy. I do have some fine tuning to do on my program, some
buttons have to disable the timer and the timer may only be enabled when
some conditions are true, also I have to take care on how the light is drawn
when it gets into service again but those are little puzzles I am going to
solve later, first I have to finish the current assignment.

Thank You again for putting me on the right track, knowing the timer
component gives me a great number of new possibilities when making programs,
it is a versatile and fun component.

Yours sincerely,
Rene
Bruce Salzman
2008-06-05 16:21:50 UTC
Permalink
Post by Rene
Post by Bruce Salzman
Use the timer component.
Hello again Bruce,
I told a friend I met last tuesday about our conversation and he said "Oh,
using the timer is very easy, just drop it onto your form". I had no idea it
was that easy, I read a lot of things about the timer component after
reading Your tip but did not know that the timer was somewhere in the bar on
top of the screen, in fact, it had not even come to my mind that it might be
there (else I would have looked for it), as far as I knew, in that bar were
only things one might draw on the form like an editbox, labels and so forth,
I thought using the timer required a lot of source code but in fact it is
just as easy as placing a button on a form. When I have some more time I am
going to thoroughly explore all the things in those bars.
My traffic light is already up and running in it's "out of service" mode,
makes me very happy. I do have some fine tuning to do on my program, some
buttons have to disable the timer and the timer may only be enabled when
some conditions are true, also I have to take care on how the light is drawn
when it gets into service again but those are little puzzles I am going to
solve later, first I have to finish the current assignment.
Great! The timer is very handy when you want things to happen independently
from what the user is doing. FYI in Delphi/Builder, 'component' generally
refers to a VCL widget on one of the component palettes.

Good luck,
Bruce

Loading...