In Direct mode:
CLEAR:DIM A$[2] PRINT A$[0]generates "Subscript out of range", as if the array had not been declared at all.
Root / SmileBASIC Bug Reports / [.]
CLEAR:DIM A$[2] PRINT A$[0]generates "Subscript out of range", as if the array had not been declared at all.
It seems the interpreter is set to ignore any DIRECT mode-exclusive command and everything else that comes in the same line after it. So it's not really a bug, or maybe only a minor bug in the parsing process.The interpreter does not ignore DIRECT-mode-exclusive commands when it is in DIRECT mode. Also, using the DIRECT-mode-exclusive command PROJECT, commands that come in the same line after it are not ignored:
PROJECT "TEST1":PRINT "QWERTY"will, assuming there is a project "TEST1", result in the current project getting changed to it, and, "QWERTY" getting PRINTed. When DIRECT-mode-exclusive commands are executed from program slots, they are not ignored, either. NEW, for example, will cause a Syntax Error. This is because, strangely, NEW is treated as a variable. In a program, you can write
NEW=7:PRINT NEWand get 7. PRINT NEW also works in Direct mode, but not NEW=7, but VAR("NEW")=7 does, but VAR("PRINT")=10 does not. Minor or not, the issue described in the top post is a bug.
The following words cannot be used because they are reserved for variable and statement names: IF THEN ELSE ENDIF GOTO GOSUB RETURN ON FOR NEXT WHILE WEND REPEAT UNTIL BREAK CONTINUE DEF END VAR DIM AND OR XOR NOT DATA READ RESTORE PRINT INPUT LINPUT CALL TRUE FALSE SWAP OUT COMMON USE EXECBased on this, PRINT is reserved, so you can't set it - no VAR("PRINT"). NEW is not reserved, so you can set its value - yes VAR("NEW"). However, while in DIRECT mode the system is trying to interpret it as a DIRECT command instead of a variable. Within EDIT mode, you can set any of the DIRECT mode only commands as variables since they have no special meaning there. The main takeaway from this is to not use the DIRECT only commands as variables while in DIRECT mode. I doubt most people will actively try this, as they are clearly marked as instructions in the documentation. On the behavior of commands when combined: this can be see in Petit Computer as well - there are certain statements that can't be combined with colons and have to go on their own line (I ran into this a lot when trying to make a minifier for PC). I expect the same thing will happen in SmileBASIC as well.
They also forgot to make "MML" and "PI" reserved words.I decided to look into this last night. Made a post about PI() on the Miiverse bug thread. I decided to look through every single autocomplete entry to see which ones had highlighting (thus, which ones were reserved) and I found two more unreserved keywords: TO and STEP. You can use them as names for anything without restriction, which is really bad. Also, REM is mysteriously missing from the autocomplete (not that we're losing anything as a result.) MML as a reserved name is a bit silly because it's just a hotword for the popup help. EDIT: Here is the Miiverse post I wrote about PI(). I have an addendum. You can create new commands with the name PI and they will work completely as expected, but new functions with the name of PI() are ignored as if they don't exist. Really weird.
VAR("TO")=0 FOR I = 0 TO 2 ?I '?TO NEXThttps://vid.me/cGga 'edit slackersnail educated me a lil, think its cause var returns a reference, but to what? probably preprocessor saying TO never got used as a variable so there is no reference to return. I'm silly.