Back to BASIC

I saw this nice post about learning to write programs on a TRS-80 computer.

http://baugues.com/trs-80/

I noted a number of comments on an aggregator site each suggesting using modern programming languages with interactive environments as an analogue to those days. While I agree that the interactive nature of BASIC made it approachable by the novice, I believe that the simplicity of the environment itself ( a self-contained, line-number-based editor ) and the spartan nature of the BASIC implementations of the 70’s and 80’s were also factors that allowed people to learn to code.

It’s fortunate that we have some BASIC implementations around that can still use the familiar 8-bit BASIC syntax. One of these is called Chipmunk BASIC. The author is programmer Ron Nicholson who worked for Apple and Amiga (among other prominent tech companies. ) Ron is currently an iOS developer.

One can download Chipmunk BASIC for Windows or for OS/X. For this post, I’ll be using the Windows version. I have been meaning to check out the newest OS/X version, but I just haven’t gotten around to it. Here’s the link to the Chipmunk BASIC area on Ron’s web site:

http://www.nicholson.com/rhn/basic/

You’ll need to download the Windows version ( the one that states that it is for Windows 2000/XP). Unzip the files to a folder. Find that folder and click on the chipmunkbasic executable file ( the one with the Chipmunk icon ).

cb_0

You should see a prompt like this:

cb_1

Let’s type in our first program. We’ll print the numbers 1 through 10 using a “for-next loop.” Let’s start by typing in the following line:

10 for x = 1 to 10

Press ENTER at the end of the line.

cb_2

Let’s now continue entering the rest of the program.

20 print x
30 next x

cb_3

Now, let’s execute the program by typing in the word “run” followed by the ENTER key:

cb_4

Let’s clear the screen by typing in the following:

cls

cb_5

cb_6

Now, let’s look at the program we’ve entered by typing in “list” and ENTER:

cb_7

The “new” command erases the program currently in memory. If we enter “new” and then enter “list”, you’ll see that no program listing is displayed. We erased it with the “new” command.

cb_8

Let’s clear the screen with “cls”. Let’s type in “new” again ( in case you’ve tinkered a bit since the last “new” ) and let’s enter another simple program. This one will ask you for your first name, store your response in the string variable n$, and will then use n$ to greet you by the name you entered.

new
10 print "What's your first name";
20 input n$
30 print "Hello there, " ; n$ ; "!"

Let’s run the above code:

cb_9

If we want to save this program for later use, we can use the “save” command.

save "greeting.bas"

This saves your BASIC program as a plain text file in the folder where you had installed Chipmunk BASIC. I’m afraid that Chipmunk BASIC doesn’t have a direct command for seeing the contents of the directory, but you can issue the Windows command-prompt’s “dir” command by using the “sys()” function:

sys("dir")

cb_10

Let’s erase the current program with a “new” followed by a “list” to make sure it’s gone:

cb_11

Now, let’s re-load “greeting.bas”:

cb_12

To exit Chipmunk BASIC, simply type “exit” and ENTER.

You’ll want to read through the accompanying manual BASIC_MANUAL.TXT which walks through Chipmunk BASIC’s commands, operators, and functions ( including features for opening the graphics screen and plotting points, lines, …etc. )

I think that the approach that classical BASIC takes is very friendly to the newcomer. I hope you have fun with this nice implementation of BASIC.

Advertisements

About Jim Lawless

I've been programming computers for about 36 years ... 30 of that professionally. I've been a teacher, I've worked as a consultant, and have written articles here and there for publications like Dr. Dobbs Journal, The C/C++ Users Journal, Nuts and Volts, and others.
This entry was posted in Programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s