100 Days of Code Day 84
Today’s exercise was super easy, barely an inconvenience. Just list some actions based on bit flags. Only tricky part was the reverse which I just did manually.

One again I unsuccessfully tried to take it easy on myself by just adding a bunch of built in functions. Here are the ones I added. There are still have 18 on the wanted list.
- CHDIR – Change Directory
- FILES – List Files (need to show folders too)(kind of want to return an array of strings once I have arrays)
- KILL – Delete file(s)
- MKDIR – Create a directory
- RMDIR – Remove a directory (it won’t do it unless it is empty)
- NAME – Rename/move a file.
- CURDIR – Return the current directory.
- TAB – Return a string of spaces to the desired column.
- CURSOR_LEFT – Cursor location on the X-coordinate
- CURSOR_TOP – Cursor location on the Y-coordinate
- CONSOLE_WIDTH – The width of the console window in characters
- CONSOLE_HEIGHT – The height of the console window in characters (I should test if resize works or not)
- COLOR – Change the foreground and/or background text color (0-15 are the allowed color numbers)
- RESET_COLOR – Change back to default color scheme
- LOCATE – Put the cursor at a desired location
- CLS – Clear the screen.
CURSOR_LEFT, CURSOR_TOP, CONSOLE_WIDTH, CONSOLE_HEIGHT, and RESET_COLOR are not normal parts of BASIC I added them for convenience and because it was easy. Also because I want to be able to make nice text user interfaces or text-mode games.
I couldn’t stand trying to type CLS() so I added a no-parameters shortcut in the function call parser to not look for parenthesis or parameters for CLS, RESET_COLOR, CURSOR_LEFT, CURSOR_TOP, CONSOLE_WIDTH, or CONSOLE_HEIGHT. I might go in and add some more later.
I needed TAB to be able to run today’s target program Acey_Ducey.bas. Today I do have a link it is from BASIC Computer Games by David H Ahl. It is the first one in the book. I had to change how the print command worked from printing all at once to printing expression at a time otherwise the TAB function would not work.
I had a dilemma about parsing function calls. Is a function call a statement or an expression? If it is an expression I can do things like CLS : PRINT “Hello, World”, but if it isn’t a statement I can’t do CLS all by itself. In the end I decided it is both. Both expressions and statements will accept a function call, and so far things seem to work just fine that way.
When running Acey_Ducey.bas I rediscovered that my comparison operations were not working for strings. I thought I at least had equal and not equal, but nope. I added in the string/string comparison operations. However, I didn’t add string coercion if one is a string and one something else you may have problems. I also wasn’t returning the variable correctly when comparing a variable. I also made runtime.run() print out the return value in the main function. I thought I had that working previously. Anyway here is a video of acey_ducey.bas in action. Yes I did have to fix up the acey_ducey.bas code to work with my interpreter.
