08-17-2022, 02:30 PM
#5 is a basic TRUTH check. In BASIC, **everything** tends to break down to a simple TRUE or FALSE type evaluation. If a variable, or the result of an action, gives a value of ZERO, we consider that to be FALSE. Anything else is considered TRUE.
Let's take a look at IF x > 3 THEN....
x > 3 is a simple math statement that gives us two results. (Don't believe it? Just try a little PRINT x > 3 and change the value of x a few times.) IF x is less than or equal to 3, it returns a value of ZERO, which is <FALSE>. If x is greater than 3, it returns a value of -1, which is <TRUE>. This true/false value determines whether we process that IF statement or not.
Now, let's take a look at IF X THEN....
X is a simple variable. In this case, we don't have to do anything with it, except look up its value to know our results. If X is 0, then the result is FALSE. Anything else is TRUE.
So, in the case of the following:
m2Dn = _MouseButton(2) ' button 2 processing
If m2Dn Then ' Btn 2 down
m2Dn gets its value based on the state of the right mouse button. (Mouse Button 2) If the button is down, the value is -1. IF the button is up, the value is 0.
IF m2Dn THEN .... If m2Dn is <TRUE>, then we process the code inside the IF condition. Otherwise, we don't. In this case, the only true value we can get is -1, and we only have it when the button is down. The statement basically says, "IF the right mouse button is down THEN..."
Let's take a look at IF x > 3 THEN....
x > 3 is a simple math statement that gives us two results. (Don't believe it? Just try a little PRINT x > 3 and change the value of x a few times.) IF x is less than or equal to 3, it returns a value of ZERO, which is <FALSE>. If x is greater than 3, it returns a value of -1, which is <TRUE>. This true/false value determines whether we process that IF statement or not.
Now, let's take a look at IF X THEN....
X is a simple variable. In this case, we don't have to do anything with it, except look up its value to know our results. If X is 0, then the result is FALSE. Anything else is TRUE.
So, in the case of the following:
m2Dn = _MouseButton(2) ' button 2 processing
If m2Dn Then ' Btn 2 down
m2Dn gets its value based on the state of the right mouse button. (Mouse Button 2) If the button is down, the value is -1. IF the button is up, the value is 0.
IF m2Dn THEN .... If m2Dn is <TRUE>, then we process the code inside the IF condition. Otherwise, we don't. In this case, the only true value we can get is -1, and we only have it when the button is down. The statement basically says, "IF the right mouse button is down THEN..."