OR keyword

Hello. I had some hardship with "OR" keyword.

If Boolean = True OR Value = 0 then
.....do something
End If

I was expecting the line above to check both values, but if Boolean = False
variable Value is not checked and ....do something is not executed even if
Value = 0

Is such behavior supposed to be correct?

In the code attached if line 21 quoted out the prog does what is expected. But if
line 21 unquoted and line 22 quoted out - nothing happens.

I think the meaning of the word "OR" implies diff behavior.
 

Attachments

  • Test.sbp
    1.3 KB · Views: 349
Last edited:

sitajony

Active Member
Licensed User
If you want check your value you can use this:

If Value=0 Then
If Boolean Then
'Do something...
End If
End If

or this:

If Boolean AND Value=0 Then
'Do something only if the Value=0 and Boolean=true
End If

I don't understand exactly what do you want do...
 

specci48

Well-Known Member
Licensed User
Longtime User
Hello Monsterman22,

there is nothing wrong with the OR statement - it will work as you expected.

If you activate line 21 and deactivate line 22, this expression
B4X:
If ToTheRight = True OR Click = 1 Then
will never come true, because the value of "Click" starts at 0 (as defined in line 10).
So the first time the program passes the if statement, Click is decreased by 1 in line 25 and set to -1. The second time Click is again decreased and set to -2 and so on. It will never reach 0. :sign0137:
ToTheRight ist "False" from the beginning of the program and only set to True, if Click gets 0... and that never happens as descibed above.


specci48
 
Sorry guys.My bad.
I got lost in a few lines of my own code
That is what happens when you get tired of coding for today.
:sign0013:
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…