BASIC - Introduction

As a gentle start to this series we’ll look at something suitably basic - the BASIC language itself.

The BASIC language

Originally developed at Dartmouth in 1964, BASIC is a simple unstructured language influenced by FORTRAN and ALGOL. It was designed to be an easy to learn language for people who were not experienced computer scientists. It achieved wide popularity in the 1980s when it was included in many home computers and in the 1990s-2000s was in common use on Windows as Visual Basic and Visual Basic.NET, which included object orientated features.

BASIC on MTS

The version of BASIC in MTS was developed at the University of Michigan and appears to date from the early 1970s, with the first version appearing in D2.0. The implementation is close to Dartmouth Basic, with some minor changes such as using ** instead of for exponentiation.

Prerequisites

No special installation instructions to get BASIC running - just do the standard D6.0 setup as described in this guide and then sign on as a regular user such as ST01.

Running BASIC

Type $run *BASIC to start. Unlike other compilers on MTS, this will put you in a self-contained environment where you can create, run, debug and organise BASIC programs.

When you start BASIC you will see the : prompt. Here you can enter commands, starting with /, to control the BASIC environment. Use /open NAME to create a new program called NAME. This will start a new file in memory that will last for the rest of the session; to save the current version to disk do /save. Note the files are saved in a special, sequential format that can only easily be read by BASIC.

To enter the actual program you can type lines starting with a line number. To correct lines you can retype it; there are also / commands such as /alter to do simple line editing. Type a line number on its own to delete it. As it is a separate environment you can’t use tools like $edit to visually edit files; you could create a text file outside of BASIC and use /include FILE to import it, however.

To view the code, type /list; to execute the program, type /run. BASIC will then compile the source file and if there are no syntax errors start to execute it. If there are any run time errors you will enter the debugger which has a > prompt. Here you can /display variables, change them with /modify and either /continue or /stop execution.

To leave BASIC, type /bye, remembering to /save first if you want to keep your program. When you start BASIC again, use /permcatalog to view the programs on disk and /open to load one.

Hello world

Here’s a terminal log of how to start BASIC and create a simple program.

# $run *basic
: /open hello
&  "HELLO" has been created.
: 10 for i = 1 to 5
: 20 print "Hello World!"
: 30 next i
: /run
  Hello World!
  Hello World!
  Hello World!
  Hello World!
  Hello World!
+  Program Ends
: /save
& Done
: /bye
&  Off at 21:53:35 on 11-17-14

In the next post we’ll look at BASIC language features in more detail.

Further information

See the Wikipedia article for more details on the history of BASIC. In 2014, Dartmouth created the website BASIC at 50 which has some interesting background on the creation of the language. TIME did an article looking at BASIC’s legacy.

For the MTS version, MTS Volume 10 offers a complete description.

There’s also a great beginner’s introduction called “Fundamental Use of the Michigan Terminal System (Including Simple MTS BASIC)” by Thomas J. Schriber from the UM Business School, which is available in the Hathi Trust archives or on Google Books.

Comments

comments powered by Disqus