NXC: compile error concerning "Wait()"

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

NXC: compile error concerning "Wait()"

Post 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);

}
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

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

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 2 guests