Ok, we need to hook up at a bar and have a beer and talk this through.... so you guys are saying the IF is in fact a decision and not a simple ON arriving at the index zero, print the index zero?? The IF statement in your example Steve simply says "IF a", which I have always read "On reaching a " or " If the loop index has reached a .. print it's value"
It seems, even if I make a = 0, which should be a True statement (ie a = 0 : If a then Print "True" else Print "False" comes up with False) we don't take away the decisional aspect of "If a"
I appreciate the lesson here. Thanks guys.
You're over-complicating the IF statement.
The IF statement tests for zero. That's all it does. Any other comparisons are actually done by the expression in the IF statement, not IF itself.
IF <value> THEN
<value is not zero>
ELSE
<value is zero>
END IF
IF does not test for equality, greater, lesser, or anything else. It simply checks for zero. In fact, the machine code for this ends up as "Jump if Zero" (JZ) and "Jump if Not Zero" (JNZ).
So everything between IF and THEN is actually an
expression., which returns a numeric result.
In BASIC, an expression is basically anything that can be turned into a value: "3" is an expression, "4 + 5" is an expression, and "A < Y" is an expression that returns a Boolean result.
And since a Boolean result is either On or Off, we treat Off as zero and On as -1 (Because signed binary integers are negative when the left bit is on. It's more complicated than that, but that's how the "negative" flag works in machine language.)
So things like IF X=Y are actually two separate operations: the expression (X=Y) is evaluated first and returned as a single value. The IF statement then jumps to the ELSE or END IF when the value is non-zero.
To understand Boolean expressions a bit more, consider these statements:
PRINT 0
PRINT 1
PRINT 0=0
PRINT 0=1
PRINT 1=1
PRINT 0=0 prints -1, because when the = is used in an expression, it's a test for equality. And a test for equality returns -1 when the two values are equal.
Likewise 0=1 returns 0, and 1=1 returns -1
Once you understand the separation between statement and expression, you'll better understand how to use the IF statement to write complex and useful tests.