TOPS-10: BASIC
BASIC on TOPS-10 is very similar to the version of Dartmouth BASIC from 1968. It runs in its own environment where you can edit programs and load/save file, and is interpreted rather than compiling source to machine code first.
Language features
As in 4th edition Dartmouth BASIC, the DEC version supports
LET(optional) to define variables,DIMENSIONto declare arrays.PRINT,INPUTfor I/OREAD,DATAto encapsulate data in a programIF…THENfor conditionalsFOR..NEXTfor loopsGOTO,ON…GOTO,GOSUB&RETURNfor transfer of control.DEF FNfor single line functions
END is needed as the last statement of the program.
The default variable type is floating point. String variables are
available by suffixing the name with a $. Both types can be formed
into arrays using DIMENSION. There is no integer type, but there is
a matrix capability via the MAT keyword.
It also has these common extensions to Dartmouth 4th edition
STOPwill half the programREMfor commentsCHAINto load in a new program from the existing program- Page and margin control
- String concatenation via
+, string/number conversion viaASC/CHR - Character access via
LEFT$,MID$etc. - Access to disk files via
FILE.
Controlling the interpreter
Start BASIC with R BASIC. Lines starting with a number are taken as
part of the program. You can correct a line by typing it again and
delete a line by just typing its line numbers.
Lines not starting with a number are commands.
| Command | Meaning |
|---|---|
BYE |
Logs out of TOPS-10 |
CATALOG |
List files on disk |
DELETE range |
Delete multiple lines |
HELP |
Prints the help file |
KEY / TAPE |
Switch between keyboard and paper tape |
LIST [range] |
List program with optional line number range |
MONITOR |
Returns to TOPS-10 |
NEW [filename] |
Start a new program with optional filename |
OLD filename |
Read in an existing program from disk |
QUEUE filename |
Print filename to printer |
RENAME filename |
Change name that program in core will be saved to |
REPLACE [filename] |
Replace filename with program in core |
RESEQUENCE |
Renumber the program |
RUN |
Execute program |
SAVE [filename] |
Save program in core to filename |
SCRATCH |
Remove the program from core |
SYSTEM |
Returns to TOPS-10, erasing core |
UNSAVE filename |
Deletes filename |
WEAVE filename |
Merges the file with the current one in core |
Files are not saved to disk unless you type SAVE. Both MONITOR and
SYSTEM will return you to TOPS-10, the difference being that
MONITOR will preserve core (see how jobs work) and SYSTEM does not.
Running TPK
As a demonstration, we'll run the the TPK algorithm. in BASIC. This
uses the 4th edition version unchanged. I created the file on my PC
and loaded it into my TOPS-10 account using the techniques described
here. Then when I start BASIC I use the old command to read this
from disk.
.r basic READY, FOR HELP TYPE HELP. old tpk READY list TPK 15:36 07-MAR-79 100 REM TPK ALGORITHM IN BASIC 110 REM 120 DEF FNT(X) = SQR(ABS(X)) + 5*X**3 130 REM 140 REM MAIN PROGRAM 150 DIM A(11) 160 LET N=11 170 PRINT "PLEASE ENTER", N, "NUMBERS" 180 FOR I = 1 TO N 190 INPUT A(I) 200 NEXT I 210 PRINT "RESULTS ARE" 220 FOR J = 1 TO N 230 LET K = N - J + 1 240 LET R = FNT(A(K)) 250 IF R > 400 THEN 280 260 PRINT R 270 GOTO 290 280 PRINT "TOO LARGE" 290 NEXT J 300 END READY run TPK 15:36 06-MAR-79 PLEASE ENTER 11 NUMBERS ?10 ?-1 ?1 ?2 ?3 ?4 ?4.3 ?4.305 ?4.303 ?4.302 ?4.301 RESULTS ARE 399.886 TOO LARGE TOO LARGE TOO LARGE 399.609 322 136.732 41.4142 6 -4 TOO LARGE TIME: 0.00 SECS. READY system EXIT .
Note that the line numbers in BASIC will not be recognised by TOPS-10
native commands as they expect 5 digit line numbers. However, the SOS
editor has a /BASIC switch that does understand these so can be used
to edit BASIC code outside of the interpreter.
BASIC programs on the DECUS tapes
There are a number of user contributed BASIC programs on the DECUS tapes (which were discussed briefly in the last article). Component 72 is a snapshot of the Dartmouth program library. Component 97 is a set of lessons for BASIC written in BASIC itself. Component 103 contains some mathematical routines in BASIC and Fortran.
Let's restore and run the teaching program in component 97 as an example. Looking at the trailing-edge page, component 97 will be on tape DECUS 10-LIB-1:
DECUS 10-LIB-1 5.64 Mbyte 902
Contains 10-3 through 10-138 compressed extracted
except 10-101 tape image files
If you click on the extracted files link next to this you will see all files on the tape. Search on the page for 97.inf and you will see below that a set of BASIC files.
1 25(7) <007> 43,50014 31-Mar-75 dcus:[43,50141]97.inf
12 1467(36) <007> 43,50014 9-Oct-70 dcus:[43,50141]tutr01.bas
9 1099(36) <007> 43,50014 9-Oct-70 dcus:[43,50141]tutr02.bas
11 1311(36) <007> 43,50014 9-Oct-70 dcus:[43,50141]tutr03.bas
10 1202(36) <007> 43,50014 9-Oct-70 dcus:[43,50141]tutr04.bas
11 1379(36) <007> 43,50014 9-Oct-70 dcus:[43,50141]tutr05.bas
Take a note of the user ID for this component - [43,50141].
On the previous page, download a copy of the compressed tape image and
decompress it with bzip2 -d decuslib10-01.tap.bz2. Copy this under
your simh directory, press Control-E on the console and attach the
tape:
sim> at mta0 decuslib10-01.tap %SIM-INFO: MTA0: Tape Image 'decuslib10-01.tap' scanned as SIMH format sim> c
Login as the operator (user 1,2 password failsa) and restore the files
using BACKUP. Here I'm going to put all the files in my home directory
for user [200,200] but they can be placed anywhere you want.
.login 1,2 JOB 11 KA603 TTY1 Password: [LGNJSP Other jobs same PPN] 1100 22-Mar-79 Thur .r backup /tape mta0: /restore dskb:[200,200]=dcus:[43,50141]*.* !43,50141 DCUS "Done /^C
Note it will take about a minute to restore the files as the tape needs to be read sequentially.
Now switch over to your user account and run the newly restored program:
.r basic READY, FOR HELP TYPE HELP. old tutr01 READY run TUTR01 11:02 22-MAR-79 WELCOME TO TIMESHARING PDP-10.WE WILL TRY TO TEACH YOU ENOUGH ABOUT THE SYSTEM IN THIS SITTING SO THAT YOU WILL BE ABLE TO WRITE YOUR OWN COMPUTER PROGRAMS.
Further information
On Bitsavers, the 1974 BASIC Conversational Language Manual is probably the best guide for this version of BASIC. There's also 1968's Advanced BASIC for the PDP-10 from which the 1974 version looks to have been derived.
Both manuals draw material from Dartmouth's documentation (see their manual for a comparison). Interestingly, the 1968 DEC manual notes Dartmouth as the registered trademark holder of BASIC, and thanks them for using the material in their manual. The 1974 manual has no mention of BASIC being registered nor any acknowledgements to Dartmouth.
Questions, corrections, comments
I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com and I will add it here and update the main text.