# Or condition help

For some reason, the ‘or’ on the 1st line has a syntax error but the one on the 8th line doesn’t. Please help.

if (Bleft.velocity(rpm)>-1 <1) or (F_Right.velocity(rpm) >-1 <1)){

F_Left.spin(reverse);
F_Right.spin(forward);
B_Right.spin(forward);
Bleft.spin(reverse);

}else if (F_Left.velocity(rpm)>-1 <1) or (B_Right.velocity(rpm) >-1 <1)){

F_Left.spin(forward);
F_Right.spin(reverse);
B_Right.spin(reverse);
Bleft.spin(forward);

}

You have unballanced parens and other issues You want
if ( ( B_left.velocity(rpm)>-1 ) || (F_Right.velocity(rpm) > -1) ){

This part (Bleft.velocity(rpm)>-1 <1)
doesn’t make any sense are you saying if the RPM > -1 or RMP is <1

2 Likes

Vexcode V5 is based on C++. If you google the “or” operator for C++, you get “||”. So or would be represented by ||.

1 Like

I did that because I’m looking for all the numbers inbeetween -1 and 1. How can I make it so it’s >-1 and <1?

-1 … 1 is a pretty narrow range. Is that what you want?

Yes, I do.
I need 20 charcters
I need 20 charcters

if ( ( ( Bleft.velocity(rpm) >-1 ) && (Bleft.velocity(rpm) <1 ) ) || ( (F_Right.velocity(rpm) -1) && (F_Right.velocity(rpm)<1) ) ) {

#If the Bleft velocity is between -1 … 1 or if F_Right velocity is between -1 … 1 then

3 Likes

Presumably defining a deadzone? Best to make the thing you’re comparing with the same type as the rest of the query so you don’t have to look up how casting happens behind the scenes, so use 1.0 instead of the 1 that looks very integer. Though I suppose the worst that could happen would be -1.99 and +1.99 registering as dead. (That last is speculative extrapolation without R’ing TFM to check floors and rounds, so apply salt.)

1 Like

For reference, u89djt’s comment on R’ing TFM stands for “Reading The Field Manual” which is what you should probably be doing before making these posts on cpp syntax: cppreference.com

Also, what some people here are trying to emphasize is that your deadzone of -1 to 1 may be too small. Consider increasing its range.

6 Likes