first its IF BUTTON is pressed AND the button is #A (or whatever)
for == its IF BUTTON is or = #A THEN...
but yeah i guess they could in some cases be switched out.
but if its like IF CAT==1 AND DOG==1 THEN..
you cant do
IF CAT==1==DOG==1
it just dosent work that way.
but i think you can also do like
IF BUTTON=!#UP
or something like that
short version:
AND means like more than one thing like "i want cookies AND milk"
= (which can be == which is basically the same)
means it equals something like lets say you have a variable named MILK and milk equals 0 so:
MILK=0
IF MILK==0 THEN (stuff)
its basically just that
I think Person(JP) explanation isn't clear.
What AND does is compare the bit representation of two values and return the value build by the logic operator AND.
For example if you compare 3 AND 6 it will pass. 3 in bit is &b011 and 6 is &b110, and since the second bit match the returned value will be &b010 aka 2.
If you compare 3==6 you will get false since they are not the same number
In your example, the difference between AND and == is this:
If you set a button to == the command after (in this case BEEP) only works if that button and no others are pressed.
If you set a button to AND the command after works as long as that button is pressed. It doesn't matter what else is being pressed also.
Both "AND" and "==" are the operators. A combination of "value", "operator" and "value" (like "3 AND 8") is an "equation". An "equation" always yields one value. You can confirm it as follows.
? 3 AND 2
? 16==16
? 16==8
The results of the preceding equations will be 2, 1 and 0.
When you call Button() you get back not a number, but a set of on/off bit flags encoded into a number. If you look at the number in binary you get a 1 or 0 for each button. So when you AND it with a number or constant (Please use the #A, #LEFT, etc. constants it makes your code more readable) you are really just isolating that bit to see if it is False (0) or True (not 0) or released/pressed.
If you look at all the button constants (#A, #B,#UP, etc) they are powers of 2, a consequence of this binary math. So as stated by others when you use == you check for equal to which matches a specific state for all the buttons not just one. if button() == (#A + #B) for example would only be true if the A and B buttons are pressed and nothing else. You use AND to check buttons individually.