In C++ there is a condition, AND NOT which uses the syntax “!”.
An example of this is: variable!=2
is there any ! command in PBASIC? If not, what syntax would I use to say “IF lightSensor1 DOES NOT EQUAL 1 THEN…”
thanks
In C++ there is a condition, AND NOT which uses the syntax “!”.
An example of this is: variable!=2
is there any ! command in PBASIC? If not, what syntax would I use to say “IF lightSensor1 DOES NOT EQUAL 1 THEN…”
thanks
*Originally posted by CHSguard72 *
**In C++ there is a condition, AND NOT which uses the syntax “!”.
An example of this is: variable!=2is there any ! command in PBASIC? If not, what syntax would I use to say “IF lightSensor1 DOES NOT EQUAL 1 THEN…”
thanks **
IF lighSensor1 ~= 1 THEN …
Can you use the ~= between 2 variables? Where I need this, i need to say “rc_sw15~=lightOn_prev” where lightOn_prev is either a 1 or a 0. This gives me an error, saying “expected a binary operator or “)””. Can i not use this syntax between 2 varialbes or only a variable and a constant?
*Originally posted by CHSguard72 *
**Can you use the ~= between 2 variables? Where I need this, i need to say “rc_sw15~=lightOn_prev” where lightOn_prev is either a 1 or a 0. This gives me an error, saying “expected a binary operator or “)””. Can i not use this syntax between 2 varialbes or only a variable and a constant? **
I’m not exactly sure. I just know that ‘~’ is the PBASIC symbol for IS NOT.
Trust me when I tell you that the not symbol in BASIC is simply the word ‘NOT’, at least when it is at the beginning of a statement. We have fallen into the habit of writing our code to emulate C++ style if statements by using the not command:
if NOT (condition) THEN SkipifA
statement
SkipifA:
I know the new compiler uses C++ style if commands, but we decided not switch to a beta version. We just don’t trust it enough.
<> is the same as C/C++'s !=. For example:
if p1_y <> 127 then doStuff
is the same as
if NOT (p1_y=127) then doStuff
*Originally posted by CHSguard72 *
**Can you use the ~= between 2 variables? Where I need this, i need to say “rc_sw15~=lightOn_prev” where lightOn_prev is either a 1 or a 0. This gives me an error, saying “expected a binary operator or “)””. Can i not use this syntax between 2 varialbes or only a variable and a constant? **
No, we tried it yesterday.
Instead we do for bits
plow_state = ~plow_state <- that works
*Originally posted by rwaliany *
**No, we tried it yesterday.Instead we do for bits
plow_state = ~plow_state <- that works **
Plowstate? Looks surprisingly like my piece of code I think most bots are going to be similar.