Log in

View Full Version : NOT condition in PBASIC?


CHSguard72
02-02-2003, 20:01
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

Raven_Writer
02-02-2003, 20:04
Originally posted by CHSguard72
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
IF lighSensor1 ~= 1 THEN ...

CHSguard72
02-02-2003, 20:09
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?

Raven_Writer
02-02-2003, 20:12
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.

K. Skontrianos
02-02-2003, 20:58
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.

rbayer
02-02-2003, 21:01
<> 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

rwaliany
02-02-2003, 22:05
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

Greg
03-02-2003, 17:42
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.