Not command is missing?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by flim.

I found I can use And Or Xor but not 'Not', will this add in next update?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

'Not' for now :)

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

Just for fun !


Procedure.l Not(a.l)
ProcedureReturn 1 - a
EndProcedure

;
;
;

a.l

a = #TRUE

Debug Not(a)
Debug Not(Not(a))

:)

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

fweil, the OP requested a logical NOT.

What you do is a BINARY not, and thats already
implemented in PureBasic:

a = ~a
a ~a

example:

Code: Select all

a ~1MessageRequester("",Hex(a),0)
ALL bitwise stuff in PureBasic is a special character:
AND: &
OR : |
XOR: !
NOT: ~

All WORDS ("Or", "And") are logical things that
compare something and return only 0 or 1, TRUE or FALSE.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

Here's a logical Not operator procedure;)

Code: Select all

Procedure Not(a.l)
  ProcedureReturn (b Or a=0)
EndProcedure

Debug Not(0)
Debug Not(12)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

How can you write " If x = 12 Not b = 13 " with that ??

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by Danilo

How can you write " If x = 12 Not b = 13 " with that ??
How can you evaluate that in ANY language, NOT is a one argument operation. You'll get syntax error for sure with that expression! This would be a correct way to use NOT:
If x=12 And Not b=13

But as PB produces assembly errors when passing something like 'a=13' to a procedure we have to use a trick, same trick as in the procedure actually, so to get this to work you would have to do it like this:

if x=12 And Not(0 or b=13)

Agreed it's not very good, i didn't mean for anyone to actually use it in their code, better to wait for the real thing!
Post Reply