Playing with the mouse
#5
Hi NasaCow

yes your conditions in the control are very complex:
AND returns true only if both parameters are TRUE
EQV return true only if both parameters are the SAME (true or false is indifferent)

but watching nearer to the complex expression 
you use 5 conditions...the first is ACTIVE
so until you use as first operator AND you can get TRUE  (the block of code has been executed) only when Active is true plus the other conditions returns true on the other side of AND.

moreover putting 4 OR condition in sequence you must remember that  OR returns FALSE only if both the parameters are FALSE otherwise it returns TRUE... so you can expect false only when all the parameters are false 
F OR F  gives F  then  F OR F  gives F then F OR F gives false , at the end F AND F gives F  while F EQV F gives T
(I do not remember the order of execution of Boolean operator, it seems to me that first is OR and after AND...)
here a code test
Code: (Select All)
' we make some tests
Rem  AND versus EQV
Rem  wiki info https://qb64phoenix.com/qb64wiki/index.php/EQV

DefInt I
Dim iActive, ImouseX, ImouseY
iActive = 0
Locate 1, 1: Print " iActive  ImouseX   ImouseY"

For iActive = -1 To 0 Step 1
    ' the first run has iActive true while the second turn has iActive false
    ImouseX = 400: ImouseY = 100 ' ImouseX < 500 and ImouseY <200 are true
    Locate , 7: Print " "; iActive; "   "; ImouseX; "   "; ImouseY;

    If iActive And ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300 Then Print " AND works "; Else Print " AND rests";
    '  If iActive And (ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300) Then Print " AND + () work "; Else Print " AND +() rest";
    If iActive Eqv ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300 Then Print " EQV works " Else Print " EQV rests"

    ImouseX = 600: ImouseY = 300 'All ImouseX and ImouseY are false
    Locate , 7: Print " "; iActive; "   "; ImouseX; "   "; ImouseY;
    If iActive And ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300 Then Print " AND works "; Else Print " AND rests ";
    '  If iActive And (ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300) Then Print " AND + () work "; Else Print " AND +() rest ";
    If iActive Eqv ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300 Then Print " EQV works " Else Print " EQV rests "

    ImouseX = 700: ImouseY = 400 ' ImouseX>600 and ImouseY > 300 are true
    Locate , 7: Print " "; iActive; "   "; ImouseX; "   "; ImouseY;

    If iActive And ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300 Then Print " AND works "; Else Print " AND rests ";
    '  If iActive And (ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300) Then Print " AND + () work "; Else Print " AND +() rest ";
    If iActive Eqv ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300 Then Print " EQV works " Else Print " EQV rests "

Next iActive


For iActive = -1 To 0 Step 1
    ' the first run has iActive true while the second turn has iActive false
    ImouseX = 400: ImouseY = 100 ' ImouseX < 500 and ImouseY <200 are true
    Locate , 7: Print " "; iActive; "   "; ImouseX; "   "; ImouseY;

    Print iActive And ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300, ;
    '  Print iActive And (ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300), ;
    Print iActive Eqv ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300

    ImouseX = 600: ImouseY = 300 'All ImouseX and ImouseY are false
    Locate , 7: Print " "; iActive; "   "; ImouseX; "   "; ImouseY;
    Print iActive And ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300, ;
    ' Print iActive And (ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300), ;
    Print iActive Eqv ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300

    ImouseX = 700: ImouseY = 400 ' ImouseX>600 and ImouseY > 300 are true
    Locate , 7: Print " "; iActive; "   "; ImouseX; "   "; ImouseY;

    Print iActive And ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300, ;
    ' Print iActive And (ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300), ;
    Print iActive Eqv ImouseX < 500 Or ImouseX > 600 Or ImouseY < 200 Or ImouseY > 300

Next iActive

you can give a look at the results.
Reply


Messages In This Thread
Playing with the mouse - by NasaCow - 12-11-2022, 07:59 AM
RE: Playing with the mouse - by Pete - 12-11-2022, 02:47 PM
RE: Playing with the mouse - by NasaCow - 12-11-2022, 03:03 PM
RE: Playing with the mouse - by SMcNeill - 12-11-2022, 02:51 PM
RE: Playing with the mouse - by TempodiBasic - 12-11-2022, 03:10 PM
RE: Playing with the mouse - by Pete - 12-11-2022, 04:50 PM
RE: Playing with the mouse - by mnrvovrfc - 12-11-2022, 06:36 PM
RE: Playing with the mouse - by Pete - 12-11-2022, 06:39 PM
RE: Playing with the mouse - by TempodiBasic - 12-11-2022, 05:39 PM
RE: Playing with the mouse - by SMcNeill - 12-11-2022, 08:21 PM
RE: Playing with the mouse - by NasaCow - 12-12-2022, 09:38 AM
RE: Playing with the mouse - by TempodiBasic - 12-11-2022, 06:24 PM
RE: Playing with the mouse - by Pete - 12-12-2022, 12:22 AM
RE: Playing with the mouse - by TempodiBasic - 12-13-2022, 02:45 PM



Users browsing this thread: 8 Guest(s)