force logical AND or OR

Blitz3D Forums/Blitz3D Beginners Area/force logical AND or OR

koekjesbaby(Posted 2004) [#1]
is there any way to forca a logical or and not a binary one?

if you'd try this:
x = 1
y = 2
z = 4

If x And y And z
	Print "this will not be printed"
Else
	Print "this will"
EndIf
WaitKey

blitz will evaluate the "x and y and z" part binary (001 & 010 & 100) so the outcome is 0. other languages have special characters for binary Ands and Ors such as & and | and evaluate nonzero numbers and nonempty strings as true.

and it becomes even worse when you want to combine locigal and binary Ands and Ors (here binary and x and y and check if the texture is set):
x = 2
y = 3
texture = 164000320 ;a dummy texture pointer

If x And y And texture
	Print "all true"
Else
	Print "crap"
EndIf
WaitKey


and if you change "texture" to "texture>0" it evaluates as 1 (funny sidethingy, try: "print True+1") so it still does not work. i think this is very confusing and i wouldn't mind (knowing about) a method to force binary or logical Ands and Ors...


big10p(Posted 2004) [#2]
I guess you could use:

If x<>0 And y<>0 And texture<>0



WolRon(Posted 2004) [#3]
(funny sidethingy, try: "print True+1")
Why is this funny? True evaluates to 1 so obviously 1 + 1 = 2

Note that you could alternatively use:
x = 1
y = 2
z = 4
If x
	If y
		If z Then Print "Yes"
	EndIf
EndIf



jondecker76(Posted 2004) [#4]
I believe the ~ operator will do what you're looking for...

a=1
b=6

Print a And b
Print a And~ b     ;Notice the ~

WaitKey()

End




Beaker(Posted 2004) [#5]
~ is binary Not (or bitwise complement).

It's:
Print a And ~b ; read as: a And (BinaryNot(b))

How about using this:
Function LogicTrue(num)
Return (num<>0)
End Function