ScratchData LogoScratchData
Back to geek62's profile

BASIC v1

GEgeek62•Created May 1, 2016
BASIC v1
86
74
929 views
View on Scratch

Instructions

The user's manual is in another project: https://scratch.mit.edu/projects/607839063/ This is a more-or-less complete BASIC interpreter, much like what TRS-80s and Apple IIs had way back when. (Okay, it's really more like what mainframes had before microcomputers existed. Whatever.) All text entry has to go through the Scratch "ask" block. Click on the background to make that hide & show. Enter programs one line at a time, just like the old days. Some test programs are built-in; try FILES to see the list, LOAD <name> to load them, RUN to make them go, etc. Since Scratch doesn't recognize control-C, there is a pause button at the upper-right (normally faded out to be almost invisible, but fades in when you mouse over it). The play button just does RUN or CONT as appropriate.

Description

The BASIC language was of course defined by Kemeny & Kurtz at Dartmouth University. This BASIC interpreter and the Terminal and ControlButton sprites are all my own coding. I think the font is too.(?) Two of the built-in sample programs (Hurkle and Life) were adapted from "BASIC Computer Games" Edited by David Ahl, but in that book they give credit for Hurkle to Bob Albrecht, and credit for Life to Martin Gardner and John Conway. I modified both to fit in the smaller terminal window implemented here, and also modified Life quite a bit to fix and clean up the logic. I'll be shocked if there are not a ton of bugs in BASIC. Every time I run a new BASIC program I find something else that needs fixing. Let me know what you find. Gently, please. :-) When I started on this, I thought it would take a few weeks. Boy, was I wrong! Big sections had to be re-written several times when the first design couldn't handle the next feature. User-defined functions were especially tricky. Limitations: It does not support file I/O, and has only a very limited way of loading and saving your BASIC programs into list variables in memory: FILES, LOAD, SAVE, DEL commands work on these "files". (I've avoided saving cloud stuff because it would violate the spirit of the "no chatroom" Scratch rule.) Input all comes through Scratch's "ask" block, because Scratch has no sanctioned way to get incoming keystrokes other than letters/digits/arrows/space. But in practice this doesn't feel nearly as horrible as I had expected it to. It's pretty slow, especially terminal scrolling. Maybe I'll dig into that someday. For now I use CLS a lot. :-) It doesn't support PEEK and POKE for obvious reasons. Formatted output (PRINT USING) might come someday. Same for LINE INPUT, and probably a bunch of others. 12-May-2024 Tried using "import" and "export" and found a lot of weirdness. Did I never test those? Fixed some of it, but some is still broken. Especially, when you let Scratch import a list from a file, commas mess it up. That's really horrible. Who thought you could never want to import text with commas in it? 1-Nov-2017 fixed a bug in Hurkle that made the numbers in the instructions all show as 0. 22-Dec-2018 added "import" and "export" commands to let you load and save your BASIC programs in files on your computer! 7-Jan-2022 fixed a few bugs: log function, exp function, string array initialization

Project Details

Project ID107723084
CreatedMay 1, 2016
Last ModifiedMay 12, 2024
SharedNovember 4, 2016
Visibilityvisible
CommentsAllowed