Would you like to play a game?
Learning to code in the 1980s was a magical time. We typed code listings from magazines into our Commodore, Sinclair, Amstrad, Apple computer and then prayed that they worked. Some of us, myself included, didn't know that we could save our projects to tape, and our work was lost as soon as we turned off the computer. What language were we using? Beginners All-purpose Symbolic Instruction Code (BASIC) of which there were a few different versions for te home computers of the era. To load BASIC, all we needed to do was power on our computer and we were presented with a prompt that could load our games and be used to write our code.
Well That Was a Lovely Trip Down Memory Lane...so Back To the Blog Post?
Of course, writing BASIC in the 21st century may seem a little weird. We now have Python, Lua, Rust etc. But BASIC is a great way to introduce coding as it is extremely easy to read and provides a base from which the learner can learn other languages.
So How Can I Run BASIC in 2021?
I've found two ways and I shall start with the most...BASIC ;)
I never put my blog posts behind paywall or pop ups because quite frankly that is annoying and prevents anyone from accessing the content. I will always keep my blog content free of charge. But I do ask that if you are able and willing, that you buy me a "coffee" as it helps me to pay for hosting this blog, and to buy stuff to hack from Poundshops / Dollar Stores / Aliexpress which are used in free projects and reviews on this blog. It is You dear reader who make this possible, and I am immensely grateful for your support.
I found this by pure chance, but it instantly made me smile.
Found via Richpl Github page, PyBASIC is a BASIC interpreter written in Python.
How Do I Install PyBASIC?
The simplest way is to download the ZIP file and extract the contents to a folder on your computer. If you are a Git user then the repo can be cloned.
git clone https://github.com/richpl/PyBasic.git
How Do I Use PyBASIC?
In the download folder run this command to open the PyBASIC interpreter.
I can now write BASIC code in the interpreter and luckily for us there is a page full of documentation covering how to use PyBASIC.
But I did have a play and I wrote something to print nice messages on the screen.
10 INPUT "What shall I say? : " : A$ 20 INPUT "How many times shouw I say it? :" : B 30 FOR I = 1 TO B 40 PRINT A$ 50 NEXT I
run will start the sequence.
Shameless plug and obvious intentional typo...
How Can We Save The Code?
To save the code to a file in our home directory just type the path. Here I save the code as
namegame to my home directory.
The file is saved and we can open the file another time by using the load command.
So What Is the Other Way?
When I moved from Commodore computers, my parents bought me a PC (486 DX 33 with 4MB RAM and a 120MB hard drive) and on that machine I played DOOM, Star Wars: X Wing and wrote some basic batch scripts. But I also learnt a little BASIC via QBasic which came bundled with MSDOS 6.22.
I recently wrote a feature for Linux Format, covering retro PC emulation and I went back to this era, showed off how to write BASIC on a virtual 486 and ran Windows 3.1 after a long hiatus.
The QB64 team contacted me and pointed out that there is a modern day version of QBasic, QB64.
I like QB64. It is easy to use, looks just like QBasic and I can make executable applications from it!
All we need to do is download the relevant package for our operating system, extract the contents and then run the
qb64 application from the folder.
I adapted the code that I wrote for PyBASIC to QB64 syntax, merely editing lines 10 and 20. QB64 has syntax and error highlighting built in! marvelous!
10 Input "What shall I say? : "; A$ 20 Input "How many times shouw I say it? :"; B 30 For I = 1 To B 40 Print A$ 50 Next I
Running the code is simple and we get a quick demo of QB64.
Sure, I said that we can make an executable directly in QB64, well here we go! By selecting Run >> Make Executable Only we can create a file in the QB64 directory which runs directly from the terminal / desktop.
10 PRINT "Happy Hacking"
Have fun with these BASIC applications. Play around with the language, take a look through Usborne books 1980s computing books for inspiration