This is an old revision of the document!
This page is under construction by user IRL. Please don't mess with it until I've removed this message. I'll be working on this over the next few hours.
— irl 2013/07/14 16:16
You should read a tutorial on using one of the available text editors before reading this tutorial. This tutorial will assume that you're comfortable running programs from the EXEC and creating text files.
For a full guide to the BASIC language available, see the original manual.
This section will explain the fundamentals of creating a BASIC program, compiling and running it.
BASIC programs require line numbers. You should increment each line by 10 to allow for adding lines in between later.
Start by creating a file with the file extension of .B20 with the contents:
10 PRINT “Hello, World!”
This is the infamous Hello, World! program for the TOPS-20 flavor of BASIC.
To run the program, start the BASIC program:
@BASIC
You will now need to load your program. At the READY
prompt, type:
OLD
You'll then be prompted for the filename of the source file you created. For instance, if you called the file HELLO.B20
then that's what you should enter.
At the next READY
prompt, type RUN
to run the program. You'll see “Hello, World!” printed on the output.
In order to build the program for use without the BASIC program, type BUILD
. Then return to the EXEC by typing MON
. Assuming the program was named HELLO.B20
, you should now see a HELLO.EXE
in the same directory. When you run this, you'll see the “Hello, World!” output as before.
Variable assignment in BASIC is pretty similar to every other programming language. It takes the form of:
VAR = VALUE
or (optionally) LET VAR = VALUE
Variables do not need to be declared before use. Standard arithmetic operations like +, -, / and * are available for use with either number literals or variable names.
BASIC variable types are determined by an optional suffix to the variable name. A suffix of $ indicates that the variable holds a string. A suffix of % indicates that the variable holds an integer. No suffix indicates that a variable holds a number (possibly with fractional part).
It is important to remember that X, X$ and X% are all different variables, not just different interpretations of the same variable.
Users should feel free to add their programs to this section.