View Full Version : quick c question
shobuda999
21-02-2005, 15:45
is it possible to do something like
variable1 = variable2;
if both variables are ints? for some reason, we're not able to do this and I'm pretty sure its allowed.
thanks,
Dan
is it possible to do something like
variable1 = variable2;
if both variables are ints? for some reason, we're not able to do this and I'm pretty sure its allowed.
thanks,
Dan
What happens?
nehalita
21-02-2005, 15:53
it should be fine. what is the code exactly?
shobuda999
21-02-2005, 15:54
What happens?
I get a syntax error on the line below, but when I comment out the var1 = var2;
line above it compiles fine
shobuda999
21-02-2005, 16:17
[above]
int counter = 0;
int tracker = 0;
counter ++
[below]
if (counter<60)
{
arm = 0;
}
tracker = counter;
else if (counter<tracker+32)
{
arm = 127;
l_motor=r_motor=191;
}
tracker = counter;
else if(counter < tracker + 55)
{
l_motor=r_motor=127;
arm = 255;
}
this is for dead reckoning without any kind of sensor using a clock of sorts.
i know this seems kind of strange, the reason I'm doing it this way is so I can easily make slight changes without having to change every value
thanks,
Dan
if (counter<60)
{
arm = 0;
}
tracker = counter;
else if (counter<tracker+32)
{
arm = 127;
l_motor=r_motor=191;
}
tracker = counter;
else if(counter < tracker + 55)
{
l_motor=r_motor=127;
arm = 255;
}
You have it being set between the else ifs.
there is not if that the else is attached to.
This is what is giving you the error, not the variable setting itself, just the placement of the setting.
Also note: you are setting tracker to counter before you check if it less than counter.
shobuda999
22-02-2005, 13:51
:P thanks, I don't know what I was thinking. I was trying to get an autonomous mode done an hour before ship
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.