IF OR Statement
xrmichael
Posts: 79
Can someone tell me what i have wrong with the syntax of this command
IF ((x <> 'ON')or(x <> 'OFF')){do this}
Basiclly i want to do something if x is not equal to on or off.
Thanks
IF ((x <> 'ON')or(x <> 'OFF')){do this}
Basiclly i want to do something if x is not equal to on or off.
Thanks
0
Comments
it should be:
You want this: or this
I wasn't passing judgement on the logic. I was just showing the proper syntax.
Thanks, back on track again now.
Edit: Does OR have to be capitalized? I always use || for logical or and && for logical and.
if (X is not 'ON') and (is not 'OFF' )
or if( X <> 'ON' and X <> 'OFF') { // do something }
with or, it's always true because X will always be "not 'ON" or "not OFF". One of those 2 will always be true so the condition will always fire.