Logical NOT Operator (' ! ') in If-statements.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Logical NOT Operator (' ! ') in If-statements.

Post by Dude »

coder14 wrote:On the flip side this should not work either:

Code: Select all

a.s = ""
b.s = "abc"
If a : Debug "a" : EndIf
If b : Debug "b" : EndIf
But it does. :lol:
Well, it only shows "b" in the Debug Output for me. So, it works correct here.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Logical NOT Operator (' ! ') in If-statements.

Post by Thunder93 »

Dude wrote:Well, it only shows "b" in the Debug Output for me. So, it works correct here.
:lol: Same observation and opinion as I had came up with earlier when having seen that.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Logical NOT Operator (' ! ') in If-statements.

Post by idle »

Code: Select all

a.s 
b.s = ""
c.s = "abc" 

If @a : Debug "a is set" : EndIf
If @b : Debug "b is set" : EndIf  
If @c : Debug "c is set" : EndIf  

If Not @a : Debug "a not set" : EndIf
If Not @b : Debug "b not set" : EndIf
If Not @c : Debug "c not set" : EndIf  
m@kes sense doesn't it?
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Logical NOT Operator (' ! ') in If-statements.

Post by Thunder93 »

idle wrote:m@kes sense doesn't it?
It does m@kes sense LOL.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Logical NOT Operator (' ! ') in If-statements.

Post by idle »

Thunder93 wrote:
idle wrote:m@kes sense doesn't it?
It does m@kes sense LOL.
it works but I'm not sure if it makes sense, I'm away in the Land of Grey and Pink :mrgreen:
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Logical NOT Operator (' ! ') in If-statements.

Post by Thunder93 »

With a.s your declaring a variable type.

With the usage of @ in the If-statement for the a variable, it's returning zero because there's no address until it's set.

With b variable and just specifying "", now variable has been set and address exists, no longer returning 0.

The Not operator works because it's going by addresses, hence numeric and not string.

... you know all this. Why wouldn't this make sense? :lol:
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Logical NOT Operator (' ! ') in If-statements.

Post by idle »

Thunder93 wrote:With a.s your declaring a variable type.

With the usage of @ in the If-statement for the a variable, it's returning zero because there's no address until it's set.

With b variable and just specifying "", now variable has been set and address exists, no longer returning 0.

The Not operator works because it's going by addresses, hence numeric and not string.

... you know all this. Why wouldn't this make sense? :lol:
you missed the part, I'm away in the Land of Grey and Pink. otherwise it m@kes sense!
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Logical NOT Operator (' ! ') in If-statements.

Post by Thunder93 »

idle wrote:you missed the part, I'm away in the Land of Grey and Pink. otherwise it m@kes sense!
I'm not wanting what you having... There's lot already that doesn't make sense to me, don't need the enhancements. :mrgreen:
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Logical NOT Operator (' ! ') in If-statements.

Post by the.weavster »

idle wrote:you missed the part, I'm away in the Land of Grey and Pink.
And later will you be standing on a golf course, dressed in PVC? :mrgreen:
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Logical NOT Operator (' ! ') in If-statements.

Post by idle »

the.weavster wrote:
idle wrote:you missed the part, I'm away in the Land of Grey and Pink.
And later will you be standing on a golf course, dressed in PVC? :mrgreen:
:lol: true, it's been known to happen!
Windows 11, Manjaro, Raspberry Pi OS
Image
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

Re: Logical NOT Operator (' ! ') in If-statements.

Post by coder14 »

Dude wrote:
coder14 wrote:On the flip side this should not work either:

Code: Select all

a.s = ""
b.s = "abc"
If a : Debug "a" : EndIf
If b : Debug "b" : EndIf
But it does. :lol:
Well, it only shows "b" in the Debug Output for me. So, it works correct here.
That's boolean on strings - so NOT should work too.

Technically if (If a$) is allowed (If Not a$) should be allowed too.
Post Reply