Problems with Bricxcc (NXC) / thousands of mistakes

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
flykai
Posts: 1
Joined: 28 Jan 2012, 14:40

Problems with Bricxcc (NXC) / thousands of mistakes

Post by flykai »

Hello, I have a problem with my program: everytime I tried to compile the whole program, it say's ";" expected...

I've searched in the program if there is one missing, but I hadn't found something (sorry for my bad english).

Here's my program (isn't finished yet):

Code: Select all


task main()
{
long xmax ;
long ymax ;
int weiß ;
int neunziggrad[120];
int xturns;
int yturns;
int rechts;
int drehungen;
int links[];
int rwinkel[90];

int sec = 0;
int weis = 90;

SetSensor(IN_1, SENSOR_LIGHT); //Rechts
SetSensor(IN_2, SENSOR_LIGHT); //Links

}


sub motorRechts(int drehungen)
{RotateMotor(OUT_A, 30, drehungen*360);}
sub motorLinks(int drehungen)
{RotateMotor(OUT_B, 30, drehungen*360);}


task rechterwinkel ()
{
while (rwinkel=1);
{
OnFwd(OUT_C, 75);
OnFwd(OUT_B, 75) ;

if (SENSOR_1 == 1); //Rechts wird getroffen
{
 if (links=1)
 {
 Off(OUT_C);   //bf
 Off(OUT_B);
 rechts = 0;
 links = 0;
 }
OnRev(OUT_C, 75);  //Beide Rückwärts
OnRev(OUT_B, 75);
rechts = 1;
Wait(150);
OnFwd(OUT_C, 75);  //Links vorwärts
Wait(50);
OnFwd(OUT_B, 75);  //Rechts vorwärts
}



if (SENSOR_2 == 1) //Links wird getroffen
{
 if (rechts == 1)
 {
 Off(OUT_C);
 Off(OUT_B);
 rechts = 0;
 links = 0;
 }
OnRev(OUT_C, 75);  //Beide Rückwärts
OnRev(OUT_B, 75);
links = 1;
Wait(150);
OnFwd(OUT_B, 75);  //Rechts vorwärts
Wait(50);
OnFwd(OUT_C, 75);  //Links vowärts
}
if ((SENSOR_2 == 1)&&(SENSOR_1 == 1))
{
Off(OUT_C);
Off(OUT_B);
rechts = 0;
links = 0;
rwinkel=1
}


task feldfahrt()      //1
{
while ((SENSOR_1 < 90) && (SENSOR_2 < 90))
{
motorRechts(1);
motorLinks(1);
}

start rechterwinkel;
until  (rwinkel = 1);

OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);

while((SENSOR_1 > weiß) && (SENSOR_2 < weiß))
{
start motorRechts(1);
start motorLinks(1);
xturns = xturns +1;
}
xmax = xturns;
xturns = 0;



OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);
RotateMotor(OUT_B + OUT_A, 30, xmax*360/2);


xturns = xmax/2

OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(neunziggrad);


while((SENSOR_1 > weiß) && (SENSOR_2 < weiß))
{
start motorRechts(1);
start motorLinks(1);
}

OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);

while((SENSOR_1 > weiß) && (SENSOR_2 < weiß))
{
motorRechts(1);
motorLinks(1);
yturns = yturns +1;
}
ymax = yturns;
yturns = 0;

OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);

RotateMotor(OUT_B + OUT_A, 30, xmax*360/2);
yturns = ymax/2

while (sec < 61)
{
PlayTone(100, 100);
Wait (100)   ;
sec = sec +1;
}
start Legos   ;
}


task Legos()
{}









start feldfahrt
{}

The tasks Legos and feldfahrt aren't finished yet so they are rubbish for the moment...
I hope somebody can help me...it is important cause it's a school project.
Thx
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Problems with Bricxcc (NXC) / thousands of mistakes

Post by afanofosc »

I get a lot of errors that mean you are using an identifier that you haven't previously declared in the same scope (rwinkel, links, rechts, neunziggrad). These have actually been declared but local to task main and not visible to any code outside of task main. Perhaps they need to be globals. But then you declare rwinkel as an array of 90 ints but later try to set it to a single value. That's wrong. It looks like it really should just be an int. The same seems to be the case with links. And neunziggrad.

At the end of rechterwinkel you are actually missing a semicolon. But you are also missing at least one } at the end of rechterwinkel (seems like 2). If you code was properly indented it would be much easier to see these kind of mistakes. You also have more than one place where you say if (something=1) which is not right unless you really did want to assign a new value to your variable. Read up on == vs = online (and in the NXC Programmers Guide). You do this same thing with while(rwinkel=1) and until(rwinkel=1).

Your code reveals that my compiler does not handle certain identifiers (weiß) since it is complaining about "wei" in the error message. I would avoid such characters at this point and use 7-bit ASCII instead. Such as "weiB". That variable will also need to be declared globally or at least inside the same scope where it is used.

More variables that need to be globals (xturn, etc...)

Incorrect use of "start" with a simple subroutine (which you call correctly elsewhere).

Use of OUT_A + OUT_B in RotateMotor call when the correct usage is OUT_AB. You can't pass an NXC expression into many NXC routines that are defined as asm macros.

More missing semicolons.

So was the class assignment to get the code to compile?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

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