barrym95838 wrote:
If T and Y aren't initialized to anything, they will be 0 at run-time, and the expression T AND Y will evaluate to 0 as well, causing no action taken. I don't see it as a syntax error, unless I'm missing something.
Mike B.
As Ed surmised, the problem has to do with the
TAN in
TANDY.
Commodore BASIC (which is essentially Micro-Soft BASIC) wasn't at all fussy about whitespace during program entry, which made gibberish such as
FORT=1TO1000 (
FOR T = 1 TO 1000) completely acceptable. The reason is that the tokenizer would do character-by-character pattern matches on the input buffer during code entry looking for supported BASIC verbs and functions, such
FOR and
TO. As a result, BASIC had no trouble figuring out what
FORT=1TO1000 meant, as it would tokenize
FOR and
TO, replacing them in the program text with one byte values (with bit 7 set to indicate that the byte was a token) that could not be confused with the variable
T and the literal numbers
1 and
1000.
Trouble arose only if a character string looked like a function or verb when it was actually supposed to be an expression. Hence the programmer might think that
TANDY is the expression
T AND Y, but the interpreter's tokenizer would see
TAN, followed by
DY, and would tokenize
TAN (a BASIC keyword) but leave
DY undisturbed. During run-time, the interpreter expects
TAN (and other functions of its type) to be followed by a parentheses-enclosed numeric expression, e.g.,
TAN(DY). In this case, the interpreter would encounter the token for
TAN and upon executing the corresponding code, would evaluate for an opening parentheses. Instead, it would read
D from program text and raise a syntax error.
There was some advantage to being able to omit whitespace in a program. The program would be smaller, hence would load from mass storage more quickly, a significant consideration back in the days of painfully slow tape cassettes. The program would run faster because BASIC's
CHRGET, which is responsible for reading program text and determining if the byte returned is a token or something else, would not be reading and discarding unnecessary whitespace.
Most modern forms of BASIC (but not Microsoft's QBASIC) not only tokenize BASIC keywords they also perform a similar process on variables, which usually results in unnecessary whitespace being discarded during program entry. Business BASIC implementations go even farther and generate an internal "symbol table" that is arrange for rapid look-up of variables, branch targets and subroutines. Instead of searching the program text during run-time for, say, the address of a subroutine, as is done in Microsoft BASIC, the interpreter scans the symbol table, using a binary search to improve speed. A similar process is used to find variables and access their content. The result is that the average business BASIC runs quite a bit faster than normal interpreted BASIC.