Page 1 of 1

NXC: compile error concerning "Wait()"

Posted: 13 Oct 2013, 08:29
by HaWe
hi,
the following program worked fine with my former NXC releases - now I unexpectedly get a compile error:
# Error: Too many arguments
File "c:\Temp\temp.nxc" ; line 31, position 30
# Wait( 200+ (Random(2800) );
#----------------------------------------------------------
# Error: ")" expected
File "c:\Temp\temp.nxc" ; line 31, position 30
# Wait( 200+ (Random(2800) );
#----------------------------------------------------------
what's wrong suddenly?
Has the early 2013 (February) NXC compiler been corrupted when copying the 2013-October release into the BCC folder?

Code: Select all

// Multitasking-Demo:
// 3 Motoren an die Motorausgänge A,B,C anschließen !
// die Motoren werden automatisch angesteuert,
// die Encoderwerte werden simultan angezeigt!

#define clreol  DRAW_OPT_CLEAR_EOL

task  DisplayValues() {
  while(true) {
    TextOut(0,56, "Enc.A:", clreol); NumOut(42,56, MotorRotationCount(OUT_A));
    TextOut(0,48, "Enc.B:", clreol); NumOut(42,48, MotorRotationCount(OUT_B));
    TextOut(0,40, "Enc.C:", clreol); NumOut(42,40, MotorRotationCount(OUT_C));
    Wait(10);
  }
}


task MotorControl() {
  int speed;

  while(true) {
    speed=Random(201) - 100; // ergibt eine Zufallszahl für die Motorleistung  zwischen -100 und +100
    OnFwd(OUT_A,speed);

    speed=Random(201) - 100;
    OnFwd(OUT_B,speed);

    speed=Random(201) - 100;
    OnFwd(OUT_C,speed);

    Wait( 200+ (Random(2800) ); // ergibt eine Zufallszahl für die Aktionsdauer von 200 - 3000 ms
  }
}


task main() {
  start DisplayValues;
  start MotorControl;

  while(true);

}

Re: NXC: compile error concerning "Wait()"

Posted: 13 Oct 2013, 15:03
by afanofosc
Please count the open parenthesis and the close parenthesis in that Wait statement. To me it looks like 3 vs 2. I doubt that ever compiled.

John Hansen

Re: NXC: compile error concerning "Wait()"

Posted: 13 Oct 2013, 15:54
by HaWe
yes, right, thx, I once changed a thing here and then didn't try it again.
I was bluffed by the "# Error: Too many arguments" message.