|Dartmouth BASIC, Tymshare SUPER BASIC|
BASIC-PLUS is an extended dialect of the BASIC programming language that was developed by Digital Equipment Corporation (DEC) for use on its RSTS/E time-sharing operating system for the PDP-11 series of 16-bit minicomputers in the early 1970s through the 1980s.
BASIC-PLUS was based very closely on the original Dartmouth BASIC, although it added a number of new structures. It also included a number of features from JOSS concerning conditional statements and formatting. In turn, BASIC-PLUS was the version on which the original Microsoft BASIC was patterned.
The language was later rewritten as a true compiler as BASIC-Plus-2, and was ported to the VAX-11 platform as that machine's native BASIC implementation. This version survived several platform changes, and is today known as HP BASIC for OpenVMS.
Users would sit at a terminal and type in programming language statements. The statements could either be entered into the system's command interpreter directly, or entered into a text editor, saved to a file, and loaded into the command interpreter from the file. Errors in source code were reported to the user immediately after the line was typed.
As a smart terminal with cursor control could not be guaranteed, BASIC-PLUS used the common system of prefixing all source code with a line number. The code was edited by typing in the number and then changing the contents of the following code. A line of code could be removed by typing in its line number and nothing else, thereby setting it to an empty line.
Like most BASIC implementations, the interpreter would convert keywords into a more compact "tokenized" form when the program was run. This avoided the need to repeatedly decode the keywords as strings, once converted to the tokenized form the keywords were numbers that pointed to routines to run that function. BASIC-PLUS included a
COMPILE command, but this was not a true compiler; this tokenized the entire program into the underlying "PPCODE" (Push-Pop Code) so that it did not have to occur at runtime.
The system could store a user's program in two formats. One was the editable source code in text format, created using the
SAVE command and normally placed in a .BAS file. The other was the PPCODE version of the program created by the
COMPILE command and saved to a .BAC file. .BAC files were smaller and loaded and ran faster, but could not be edited.
The virtual address space of an RSTS/E user was limited to a little less than 64KB of space. Using BASIC-PLUS, about half of this virtual address space was used by the combined command interpreter and run-time library (named the Run Time System on RSTS/E). This limited user programs to about 32 kB of memory.
Large programs were broken up into various pieces by use of the
CHAIN statement, and programs could chain to specific line numbers in a secondary program to indicate that a program should begin execution at a different point from its first line. This feature of chaining to a certain line number allowed programs to signal to each other that they were being called from another program. The use of a shared memory section called core common also allowed programs to pass data to each other as needed. Disk files could also be used but were slower.
To conserve memory, the interpreter included a garbage collecting memory manager, used for both string data and byte-code.
A running program could be interrupted, have variables examined and modified, and then be resumed.
Syntax and features
BASIC-PLUS is patterned closely on later versions of Dartmouth BASIC, including its powerful
MAT commands. On top of this, DEC added a number of unique flow-control structures.
Line numbers were positive integers from 1 to 32767. Logical lines of code could be continued on multiple physical lines by using a line feed at the end of a line instead of the normal carriage return character. For ease of external editing of the source file, later versions of BASIC-PLUS also allowed the
& character as a line-continuation character.
Multiple statements could be placed on a single line using
: as the statement separator. The system allowed tabs to be used as inline whitespace, and was used to make loops more clear, as in modern languages. Comments used either the
REM keyword or the
! character, as opposed to MS BASICs, which used
Variable names in the early versions of BASIC-PLUS could be a single letter or a single letter followed by a single digit. With the inclusion of "Extend mode" in later versions, variable names could be up to 29 characters long, and dot (.) was added as a permitted character. Every variable name still had to begin with a letter, however.[a]
As in most versions of BASIC, the
LET keyword, for variable assignment, was optional. It did have the ability to set multiple variables to a single value, like
LET A,B,C=10. The language supported three data types; floating-point numbers, integers, and strings. Variables with no suffix were floating point (8 bytes, range .29 x 10E-38 to 1.7 x 10E38, up to 16 digits of precision). Integer variables (16-bit, range -32768 to +32767) were indicated with a
% suffix, string variables (variable length) were indicated with a
Any of these data types could be used in an array of one or two dimensions, using the
DIM keyword. Additionally, the
DIM# command could be used to define a "virtual DIM" whose elements resided in file. The program would first
OPEN a file, which would assign it a number, and then the
DIM# would refer to the data in that file and could be used like any other array. This was a very useful technique for saving memory, as data did not have to be encoded into the program itself.
The language also included a number of
MAT commands to work with the entire array (or MATrix). The
MAT READ command would fill the matrix with values in a
MAT INPUT would fill the array with user-typed values, and
MAT PRINT would print out the elements in a 1D or 2D format.
MAT could also be used to set default values in a matrix using associated keywords, for instance,
MAT A=ZER would fill the A array with zeros.
TRN would transform an entire matrix, and
INV would invert it. Additionally,
* could be used on matrixes, performing the associated matrix operation.
PRINT 1,2,3 would output 1, 2 and 3 in a spaced out fashion, while
PRINT 1;2;3 would leave a single space and produce "1 2 3".
INPUT allowed a prompt string to be specified, but used the semicolon to separated it rather than the comma;
INPUT "WHAT IS THE VALUE";A.
Strings could be delimited by single or double quotes. In addition to the
ASCII functions that converted single characters to and from string format, BASIC-PLUS also supported Dartmouth's powerful
CHANGE iterated the string and returned each character's ASCII value as a slot in a numeric array. For instance,
CHANGE 'HELLO' TO X would return an array five elements long. One could reverse the operation as well,
CHANGE X TO A$ would read the individual numbers in the X array and convert it to a string.
FOR loops worked as in later versions of BASIC, and the
NEXT command could not be used in an expression. Instead, the
WHILE keywords could be used to control early exits. For instance,
FOR I=1 UNTIL 10 continue looping until I=10, with the assumption that following code would set the value of I.
BASIC-PLUS also allowed most control structures to be placed after other commands. For instance,
PRINT I IF I < 10 is the equivalent of
IF I >= 10 THEN PRINT I The opposite was also provided,
PRINT I UNLESS I = 10 was the equivalent of
IF I <> 10 THEN PRINT I. Using a conditional expression could make a loop, for instance,
X=X+1 WHILE X<100 would loop until X was 100. This offered a compact format for many common loop structures.
BASIC Plus 2
A related product called Basic Plus 2 ("BP2" or BASIC-Plus-2), was later developed by DEC to add additional features and increased performance.
It used true compilation into threaded code and wrote its output to object files compatible with the machine code object files produced by the assembler and other language systems. These object files could be kept in libraries. A linker (the TKB taskbuilder) then created executable files from object files and the libraries. TKB also supported overlays; this allowed individual routines to be swapped into the virtual address space as needed, overlaying routines not currently being used. Additionally,
BP2 programs ran under the RSX Run Time System; this RTS only occupied 8KB of the user's virtual address space, leaving 56KB for the user's program. (RSTS/E version 9 introduced separate Instruction and Data space, and the "disappearing" RSX Run Time System, permitting up to 64KB of each of instruction code and data.) These two factors allowed individual BP2 programs to be much larger than BASIC-PLUS programs, often reducing the need for CHAINing among multiple programs.
Comparison to MS BASIC
Microsoft BASIC was patterned very closely on BASIC-PLUS. Earlier versions of MS BASIC, the 1.x series, lacked integer variables, but these were added in the 2.x series that was found on many machines, including the later models of the Commodore PET and Commodore 64. The ability to place logical and loop commands in-line, like
I = I + 1 UNTIL I = 10 was not copied over and does not appear on any common version of microcomputer BASIC. MS BASIC also lacked the matrix commands.
- Before the introduction of Extend mode, white space was not required between variables and other language elements:
FOR I=STOPwould be interpreted as
FOR I = S TO P.
- Manes, Stephen (1993). Gates. Doubleday. p. 61.
- PLUS 1972, p. 2-1.
- PLUS 1972, p. 2-3.
- PLUS 1972, p. 2-6.
- PLUS 1972, p. 3-1.
- PLUS 1972, p. 3-3.
- PLUS 1972, p. 6-1, 6-2.
- PLUS 1972, p. 5-2.
- PLUS 1972, p. 3-21.
- PLUS 1972, p. 5-3.
- PLUS 1972, p. 9-17.
- PLUS 1972, p. 7-2.
- PLUS 1972, p. 7-3.
- PLUS 1972, p. 7-5.
- PLUS 1972, p. 7-7.
- PLUS 1972, p. A-1.
- PLUS 1972, p. 3-7.
- PLUS 1972, p. 3-8.
- PLUS 1972, p. 3-10.
- PLUS 1972, p. 5-12.
- PLUS 1972, p. 5-5.
- PLUS 1972, p. 5-7.
- PLUS 1972, p. 3-19.
- PLUS 1972, p. 8-14.
- PLUS 1972, p. 8-17.
- PLUS 1972, p. 8-18.
- PLUS 1972, p. 8-20.
- BASIC V2 Reference Manual (PDF). Maynard, Massachusetts: Digital Equipment Corporation. 1991.
- BASIC-PLUS Language Manual (PDF). Maynard, Massachusetts: Digital Equipment Corporation. 1972.