Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / The NOT operator

Author
Message
BriereAnthony
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 20th Apr 2011 02:26
Hello, I'm having some trouble with the NOT operator. I want to compare a character stored within a variable as a value and another character.

Here is what I tried :



The NOT operator makes my code not compile. I would like to know how to do it correctly.
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Apr 2011 02:40
In this case you would be using the "<>" for "NOT EQUAL TO" or "Greater than or Lower than"...

The "NOT" is usually for deciding whether something is 0 or 1, or even used a a bit operator.

Warning! May contain Nuts!
BriereAnthony
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 20th Apr 2011 02:43
Oh great thanks about that! I had some trouble finding the correct operators and was used to != ahah

Thanks alot for your help!
Agent
20
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 22nd Apr 2011 20:59 Edited at: 22nd Apr 2011 21:02
Just a clarification there: NOT is a logical (or boolean) operator (like AND, OR), not a relational operator (like <, >, =).

To check if a is not equal to b, you can do it two ways:

1: IF a <> b then...
2: IF NOT a = b then...

The NOT operator simply reverses the outcome of the same check done without it. Regardless of the values of a and be, one of the following two commands will always evaluate TRUE and the other one will always evaluate FALSE:

1: IF a = b then...
2: IF NOT a = b then...

You can use NOT with any type of check you'd use IF for, not just for checking for 0's or 1's. You can use it in complex formula that are made less complex by reversing checks, or with string comparisons. It's especially useful in logical bitwise operations, though these are possibly in the upper tier of understanding.

In short, if you have an expression that evaluates to TRUE, putting a NOT in after the IF will make it evaluate to FALSE, and vice versa.

Login to post a reply

Server time is: 2024-11-22 23:07:57
Your offset time is: 2024-11-22 23:07:57