Subject:
|
Re: Error in program
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Thu, 1 Feb 2001 13:08:11 GMT
|
Viewed:
|
2050 times
|
| |
| |
calvin8@t-online.de (Andi Scharfstein) writes:
>
> can somebody tell me why this little program doesn't give any output? It
> just keeps running and doing nothing...
>
> int Edges[7], CounterLength=0;
> task main(){
> SetSensor (SENSOR_2, SENSOR_TOUCH);
> until(CounterLength == 8){
> Edges[CounterLength] = (CounterLength + 1);
> ++CounterLength;}
>
> CounterLength = 0;
> until(CounterLength == 8){
> repeat(Edges[CounterLength]){
> PlayTone(440,25);
> Wait(35);}
> PlayTone(220,25);
> Wait(35);
> until(SENSOR_2 == 1);
> ++CounterLength;}}
Your array is too small, it runs from 0 to 6.
Maybe you should also put a
CounterLength = 0;
before the first until.
until(SENSOR_2 == 1);
makes it wait for the sensor being pressed.
Also, as a matter of style, I'd rather use
While(CounterLength < 8){
or even better a For loop than
Until(CounterLength == 8){
Jürgen
--
Jürgen Stuber <stuber@loria.fr>
http://www.loria.fr/~stuber/
|
|
Message has 1 Reply: | | Re: Error in program
|
| (...) Already got that answer, but thanks. (...) Done with initialization (int CounterLength=0;), isn't it? Please correct me if I am wrong. (...) Yes, you are right. But it didn't occur to me the time I wrote it. (...) (24 years ago, 1-Feb-01, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | Error in program
|
| Hi, can somebody tell me why this little program doesn't give any output? It just keeps running and doing nothing... int Edges[7], CounterLength=0; task main(){ SetSensor (SENSOR_2, SENSOR_TOUCH); until(CounterLength == 8){ Edges[CounterLength] = (...) (24 years ago, 31-Jan-01, to lugnet.robotics.rcx.nqc)
|
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|