NOT a problem.
I'm in the camp that Tempo mentioned, use of home-made logical operators. This bitwise and XOR, NOT, etc. are fun, but can be more complicated than most of the conditions I code for.
For routines like this mouse or any simple condition that even only requires two conditions met, just everyone please remember to only use a numeric representation just once in the conditional statement...
Notice these differences if we want a non-zero response between i and j...
So especially in that last example the coder who thinks IF j AND LEN(find$) is the same as IF j <> 0 AND LEN(find$) <> 0 is going to get a sad awakening. If fact, 2nd and 3rd ways of writing the condition are still using a bitwise element, but are solid in there logic for this condition. I like using the second or third method, as it saves me some typing.
Pete
I'm in the camp that Tempo mentioned, use of home-made logical operators. This bitwise and XOR, NOT, etc. are fun, but can be more complicated than most of the conditions I code for.
For routines like this mouse or any simple condition that even only requires two conditions met, just everyone please remember to only use a numeric representation just once in the conditional statement...
Notice these differences if we want a non-zero response between i and j...
Code: (Select All)
i = 1: j = 1
PRINT i AND j ' bitwise returns 1
PRINT i AND j > 0 ' bitwise returns 1
PRINT i > 0 AND j > 0 ' numeric returns -1
PRINT "--------------------"
PRINT i AND j < 0 ' zero
PRINT i > 0 AND j > 0 ' negative one
PRINT "--------------------"
x$ = "abc"
find$ = "b"
j = INSTR(x$, find$)
IF j AND LEN(find$) THEN PRINT "1" ELSE PRINT "other"
IF j AND LEN(find$) <> 0 THEN PRINT "2" ELSE PRINT "other"
IF j <> 0 AND LEN(find$) THEN PRINT "3" ELSE PRINT "other"
IF j <> 0 AND LEN(find$) <> 0 THEN PRINT "4" ELSE PRINT "other"
PRINT "--------------------"
Pete
Shoot first and shoot people who ask questions, later.