I made 3 variables--- year month day
when I use the month variable, the monitor comes up....
in case it might be worth mentioning lol...
mon
Re: mon
Right - Commodore BASIC only supports 2 letter variables. It will accept 3 or more letters, but everything after the second character is ignored.
I would suggest the usual convention of YY, MM, and DD for year, month, and day variable names.
MON is actually the command to start Supermon, so this is correct behavior. Some other surprises are TI, MX, MY, and MB. Those are all system variables and can't be used as general purpose variables.
BASIC on the C64 is kind of unique, in that it doesn't care much about separators. The interpreter pattern-matches the first beginning of a typed word against the BASIC keywords, and if there is any match, it will assume the word is a command. Only after exhausting the list of commands does BASIC assume it's a long variable name.
This is completely unlike other interpreters, which require a space (or certain other separators) between commands and arguments.
So something like FORT actually gets interpreted "FOR T". PRINTER means PRINT the variable ER. And so on.
I would suggest the usual convention of YY, MM, and DD for year, month, and day variable names.
MON is actually the command to start Supermon, so this is correct behavior. Some other surprises are TI, MX, MY, and MB. Those are all system variables and can't be used as general purpose variables.
BASIC on the C64 is kind of unique, in that it doesn't care much about separators. The interpreter pattern-matches the first beginning of a typed word against the BASIC keywords, and if there is any match, it will assume the word is a command. Only after exhausting the list of commands does BASIC assume it's a long variable name.
This is completely unlike other interpreters, which require a space (or certain other separators) between commands and arguments.
So something like FORT actually gets interpreted "FOR T". PRINTER means PRINT the variable ER. And so on.
Re: mon
This is true of all the 6502 versions of Microsoft BASIC. (e.g., Applesoft BASIC on the Apple II has the same parsing quirks.)TomXP411 wrote: ↑Mon May 01, 2023 8:24 pm BASIC on the C64 is kind of unique, in that it doesn't care much about separators. The interpreter pattern-matches the first beginning of a typed word against the BASIC keywords, and if there is any match, it will assume the word is a command. Only after exhausting the list of commands does BASIC assume it's a long variable name.
Also it's important to note that the tokenizer will even recognize keywords inside the middle of variable names. So it will interpret "SCORE" as "SC OR E". Thus "SCORE = 3" will generate a syntax error. And this program won't produce the output you'd expect:
Code: Select all
10 SC = 7
20 SCO = 0 : REM SCO and SC are the same (only the first two letters matter)
30 E = 1
40 PRINT SC : REM prints 0
50 PRINT SCORE : REM but SCORE is interpreted as SC OR E so this prints 1