12-11-2022, 03:10 PM
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
you can give a look at the results.
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.