SUPER BASIC

Last updated
SUPER BASIC
Developer Dan Lewis and Frank Bracher, Tymshare
First appeared1968;56 years ago (1968)
Influenced by
Dartmouth BASIC, JOSS, CAL
Influenced
BASIC-PLUS

SUPER BASIC, sometimes SBASIC for short, is an advanced dialect of the BASIC programming language offered on Tymshare's SDS 940 systems starting in 1968 and available well into the 1970s.

Contents

Like the Dartmouth BASIC it was based on, SUPER BASIC was a compile and go language, as opposed to an interpreter. In addition to offering most of the commands and functions from Dartmouth BASIC Version 4, in including matrix math commands, SUPER BASIC also included a number of features from the seminal JOSS language developed at Rand Corporation, [1] via Tymshare's version, CAL, and added a variety of new functions, complex numbers as a built-in type, and double precision support.

SUPER BASIC also greatly improved string handling over the rudimentary system in Dartmouth, introducing the LEFT, MID and RIGHT string functions, simple string concatenation and other features. These were later used in DEC's BASIC-PLUS, which was later used as the basis for the original Microsoft BASIC that saw widespread use in the 1980s.

History

The original Dartmouth BASIC was released in 1964 but was largely experimental at the time. It went through several revisions before becoming truly useful with the Fourth Edition when it was ported to the GE 635 machine and was published in 1968. Dartmouth specifically placed the underlying design in the public domain, so that anyone could port it to their platforms and call it BASIC. Its spread was further helped by the tireless efforts of its authors to promote it. However, as the code was designed to run on the DTSS operating system, some porting was required to run it on production systems. This led to a proliferation of versions with minor differences. [2]

Tymshare was formed within the University of California, Berkeley, initially renting out time on the University's computers on off-hours. Tymshare's original BASIC, simply Tymshare BASIC, was based on source code "from elsewhere" in the University, [3] that Dan Lewis began enhancing. Frank Bracher added the routines for file input/output (I/O), which made it far more practical than the original Dartmouth code that relied purely on DATA statements embedded in the program. Dartmouth's workflow was tape based so loading and saving individual files was not practical and direct I/O was not addressed until later versions. Bracher's I/O code had originally been developed for Tymshare's SUPER FORTRAN offering. [2]

One oft-noted feature of the system was the documentation, written by Caroline Diehl. The manuals were written in a conversational style. [3]

Tymshare maintained SUPER BASIC through the 1970s, but as the market for rented timeshare programming services dwindled the system went into maintenance and Lewis and Bracher left to do SUPER BASIC consulting for those companies still using it. Maintenance within Tymshare passed primarily to Walter Main. [3]

Tymshare filed for a trademark on SUPER BASIC on 7 January 1970, and refreshed it on 17 October 1977, which became the property of McDonnell Douglas in 1984 when the company purchased Tymshare. [3]

Language

Direct and indirect mode

Like most BASIC systems of the era, SUPER BASIC had a single command line editor that worked both as an interactive language and a program editor. Commands that were typed without a line number were executed immediately, which they referred to as "direct mode". [lower-alpha 1] If the same line was prefixed with a line number, it was instead copied into the program code storage area, known as "indirect mode". New lines were added to the program if the line number was unique, replaced existing lines with the same number, or removed from the program if an existing line number was typed in without any code following it. [4]

Program statements

Line numbers ran from 0 to 999999. [5] The DELETE (or short-form DEL) could be used to delete a range of lines using typical LIST notation, for instance, DELETE 5,10-50. [4] The ENTER command started an automatic line-number system. It took two optional parameters, a starting line number and a step, separated with BY. The starting number was assumed to be zero if not provided, and the step was 10. For instance, ENTER would produce 0,10,20,..., ENTER BY 5 would produce 0,5,10,..., and ENTER 10 BY 10 would produce 10,20,30... [6] RENUMBER took three parameters, a new starting line number, a range of lines to renumber (like 20-100) and the step. [7]

Although the built-in editor loaded and saved only the lines in the program itself, the user could edit the resulting text file to add additional commands that would run in direct mode. A common example was to edit a program and add RUN on its own line at the end of the file. When loaded, the system would see the RUN and immediately compile and start the program on loading. [8] This is unusual for BASIC systems, although this was commonly used in JOSS.

Statements

In keeping with the overall Dartmouth BASIC concept, SUPER BASIC was a compile and go system that compiled the source code when the program was run. SUPER BASIC had two commands for this, the typical RUN seen in most BASICs, as well as START which did the same thing. [9] Remarks could be placed anywhere using !. [10]

SUPER BASIC expanded the FOR statement in several ways. A minor change was to allow BY in place of STEP, and allowed the step to be placed at the end as in most BASICs, or in the middle as in JOSS and other languages. Thus FORI=1TO10BY2 and FORI=1BY2TO10 were both valid. [11] Additionally, SUPER BASIC provided alternate forms of the range definition using WHILE and UNTIL, whereas most other languages used completely separate loop structures for these. For instance, FORX=1WHILEX<Y will continue as long as X<Y, while FORX=1UNTILX<Y stops when the condition is met. [12] As in Microsoft BASIC, multiple loops could end with a single NEXT I,J, [12] although it did not include the feature of later version of MS where the index variable could be left off entirely. Finally, in JOSS fashion, one could replace the typical range specifier 1 TO 10 with an explicit list of values, FORI=1,4,5,6,10. [13]

A more major change, following the JOSS model, was the concept of "statement modifiers" that allowed an IF or FOR to be placed after the statement it controlled. For instance, PRINT"IT IS"IFX=5 is equivalent to IFX=5THENPRINT"IT IS". This can make some commonly found use-cases easier to understand. [14] It also included the syntactic sugar UNLESS which was an IF with the opposite sense; for instance, PRINT"IT IS NOT FIVE"UNLESSX=5. One could also use a loop in these cases, which made single one-statement loops easy to implement, for instance PRINTXFORX=1TO10. [15] One could also use a "bare" WHILE or UNTIL without the for, X=X+2UNTILX>10. The modifiers could also be ganged, PRINT"YES"IFA=BUNLESSN=0. [16]

Expressions

Variables

Variable names could consist of one or two letters or one letter and a digit. SUPER BASIC did not require variables to be typed, a variable could hold a number at one point and a string at another, a side-effect of the way they were stored. This required the system to test the variable type at runtime during INPUT and PRINT for instance, which reduced performance. This could be addressed by explicitly declaring the variable type using a variety of commands. [17]

In most dialects of BASIC, variables are created on-the-fly as they are encountered in the code, and generally set to zero (or the empty string) when created. This can lead to problems where variables are supposed to be set up by previous code that is not being properly called, but at run time it can be difficult to know if 0 is an uninitialized value or one with the perfectly legal 0 values. SUPER BASIC addressed this with the VAR command. There were two primary forms, VAR=ZERO which made all undefined variables automatically get the value zero when accessed, which is the normal pattern for BASIC, and VAR=UNDEF which would instead cause a "VARIABLE HAS NO VALUE" error to occur when a previously unseen variable was used in a way that attempted to access its value. The later is very useful in debugging scenarios, where the normal behavior can hide the fact that a variable being used in a calculation has not been correctly initialized. [18]

Numeric

Unless otherwise specified, variables were stored in a 48-bit single precision floating point format with eleven digits of precision. One could also explicitly define a variable as REAL A, which was the single-precision format. This was not a consideration in other BASICs where some sort of suffix, like $, indicated the type wherever it was encountered. [17]

When required, a double precision format with seventeen digits, stored in three 24-bit words instead of two, could be used by declaring a variable with DOUBLE A. [19] An existing single precision value or expression could be converted to double using the DBL(X) function. For instance, one could force an expression to evaluate using double precision using DBL(10+20). [20]

Likewise, one could declare INTEGER A to produce a one-word 24-bit integer value. [17]

A more unusual addition was direct support for complex numbers. These were set up in a fashion similar to other variables, using COMPLEX I,J to set aside two single precision slots. When encountered in programs, other statements like INPUT would trigger alternative modes that asked for two numbers instead of one, with similar modifications to READ (used with DATA statements), PRINT and others. A single complex number could be created from two singles using the CMPLX(X,Y) function, while REAL(I) and IMAG(I) extracted the real and imaginary parts, respectively, into singles. A small number of additional utility functions were also offered. [21]

Operators and functions

There were seven basic math operators: [22]

  • for exponents - the exponent is converted to a 12-bit integer
  • * for multiplication
  • / for division
  • MOD for modulo, the remainder of an integer division
  • DIV for integer division
  • + for addition
  • - for subtraction

SUPER BASIC's list of mathematical functions was longer than most BASICs, including a series of inverse trigonometric functions and logarithms for base 2 and 10. [22]

RND(X),returnsarandomnumberusingafixedsequence,canbeseededwithRND(-1)ABS(N),absolutevalueSQR(N)orSQRT(N),squarerootSINCOSTANASINACOSATNorATANATN/ATANwithtwovariables,(y,x)calculatesy/xandreturnsATNofthatSINHCOSTHTANHLOGLGT/LOG10LOG2EXPEXP2INT,asinBASIC,alwaystruncatesdownwardFIX,similartoINTbutsimplytruncatingthedecimalROUND,roundsthevaluetoclosest,unlikeINTCOMP(X,Y)COMPare,combinesasubtractionandSGN,soifX>Y=1,X=Y=0,X<y+-1PDIF(X,Y)PositiveDIFference,returnsdifference(X-Y)ifX>Y,0otherwise

SUPER BASIC included a number of functions from JOSS as well: [23]

IP(),IntegerPart,equivalenttoINTFP(),FractionPart,sameasX-INT(X)MAX(...)returnsthemaximumvaluefromalistofentriesMIN(...)returnstheminimum

Arrays and matrix math

In addition to basic math, SUPER BASIC included array functionality like many other BASIC implementations. One could DIM A(5,5) to make a two-dimensional array, and as a consequence of the way they were stored, all variables otherwise undeclared were actually DIMed to have ten indexes, so one could LET B(5)=20 without previously DIMing B. [24]

In contrast with other BASICs, SUPER BASIC allowed one to define the range of one or both of the dimensions, assuming 1 if not defined. So A in the example above has indexes 1..5, but one might also DIM A(-5:5,0:5) to produce an array that has 11 indexes from -5 to +5 for X, and 0 to +5 for Y. One could also use the BASE command to change the default, so BASE 0, for example, makes all dimensions start at 0. [24]

In addition to these traditional BASIC concepts, SUPER BASIC also included most of the matrix math features found in later versions of Dartmouth BASIC. These were invoked by adding the keyword MAT to the front of other commands. For instance, MAT A=B*C multiplies all the items in array B by their corresponding item in C, whereas MAT A=B*5 multiplies all the elements in B by 5. Functions for common matrix operations like inversion and identity were included. [25]

Binary math and logical values

As in most versions of BASIC, SUPER BASIC included the standard set of comparison operators, =, <>, >=, <=, > and <, as well as boolean operators OR, AND and NOT. In addition, # could be used as an alternate form of <>, a form that was found on a number of BASIC implementations in that era. [14] SUPER BASIC also added XOR, EQV for "equivalence" (equals) and IMP for "implication". [26]

To this basic set, SUPER BASIC also added three new commands for comparing small differences between numbers, these were >>, << and =#. The much-greater-than and much-less-than operators compared the values of the two operands, for instance, A and B in the expression A >> B. If adding B to A results in A being unchanged after the inherent rounding, >> returned true. Internally this was performed by IFA=A-B. =#, the close-to-equals, simply compared both values to an internal meta-variable, EPS, performing ABS(A/B-1)<EPS. [14]

Most dialects of BASIC allow the result of such logical comparisons to be stored in variables, using some internal format to represent the logical value, often 0 for false and 1 or -1 for true. SUPER BASIC also allowed this, which resulted in the somewhat confusing behavior of LETA=B=5, which, following operator precedence, assigns 5 to B and then returns true or false if A=B. SUPER BASIC also added true logical variables, declared in a similar fashion as doubles or complex, using LOGICAL A, and other variables could be conveyed to logical using L(). [27]

In contrast to logical comparisons and operators, SUPER BASIC also added a number of bitwise logical operators. These applied a basic logical operation to the individual bits in a word. These included BAN, BOR and BEX, for and, or and exclusive or. Additional functions include LSH(X) and RSH(X) for bit-shifting left and right, respectively. To ease the entry of binary values, constants could be entered in octal format [lower-alpha 2] by prefixing a number with an "O", like LETA=O41. [28]

Strings

SUPER BASIC allowed string constants (literals) to be enclosed with single or double quotes, so one could use PRINT "HELLO, WORLD!" or PRINT 'HELLO, WORLD!'. [29]

In contrast to later dialects of BASIC, one could assign a string to any variable and the $ signifier was not used, so A="HELLO, WORLD!" was valid. This could lead to some confusion when a user provided a value combining digits and letters, and SUPER BASIC assumed anything starting with a digit was a number. To guide the system when this might result in confusing input, one could explicitly declare string variables using STRING A. As with all variables in SUPER BASIC, these could be arrays, STRING A(5). Additionally, SUPER BASIC added the additional statement TEXT which took a second parameter to define the length of the string elements, so TEXT A(12):10 makes an array with 12 elements of 10 characters each, while TEXT B(5:10):15 is an array of six elements, 5..10, each 15 characters long. [30]

String operators and functions

SUPER BASIC included operators for = for comparison and + for concatenation. It included the following functions: [31]

ASC(S), returns the ASCII number for the first character in the string CHAR(N), returns a string with a single ASCII character, same as MS CHR() COMP(A,B), compares two strings, returns -1,0,1 depending on which is "bigger" INDEX(A,B), returns the index of B within A. Optional 3rd parameter is an offset starting point LENGTH(A), length of the string SPACE(X), returns a string consisting of X number of spaces VAL(A), looks through the string for a number and returns it STR(N), converts a number into a string LEFT, as in MS RIGHT SUBSTR, as MS's MID

Utility functions

Typical utility functions are also included: [32]

POSreturnsthecolumnoftheprintheadPOS(X)returnsthepositioninafileTAB(X)movestheprintheadtocolumnXTAB(X,N)thesameinfilenumberNDATETIME

SUPER BASIC also included pseudo-variables for PI and DPI, the later being double-precision, as well as the previously mentioned EPS to represent the smallest possible value.

SUPER BASIC included two forms of print formatting that could be used with the PRINT statement. PRINT IN IMAGE X: used a format string, in this case stored in X, in a fashion similar to what other BASICs implemented using PRINT USING or the more common examples found in C and its follow-ons. Field type included integers, [33] specified decimal formats, and exponents, as well as strings and text. % signs indicated a single digit in either an integer or real field, and # indicated a digit in an E field. [34] * and $ could be used to prefix any value. [35]

PRINT IN FORMAT worked generally the same way, the difference being that spaces had to be explicitly defined using B. Thus the format string "%% BBB %%.%%" would print two numerical values with three spaces between them, whereas if this was an image the "BBB" would be printed out with a space on either side. The FORMAT version supported a wider variety of format strings and included items like inline carriage returns, but the examples given in the manuals do not make it clear why there are two such systems when they accomplish the same thing in the end. [36]

Interestingly, the same format commands could be used for INPUT, not just PRINT. In this case the user input would be properly formatted based on the string, so 1.2345 might be truncated to 1.2 if the format is %.%. [37]

File I/O

SUPER BASIC included a file input/output system based on INPUT ON X and PRINT ON X where X is file handle, a number. The number was assigned using OPENfilenameFOR[INPUT|OUTPUT]ASFILEX. WRITE ON X was provided as an alternative to PRINT ON X, but they are identical internally. When complete, the file can be released with CLOSE X or CLOSE filename. [38] When working with files, one could read the next-read location using LOC(X) and change it using LOCATE 100 ON 2. [39] POS(X) returned the position within a form if IN FORM was being used. [40] SIZE(N) returned the file size. [41] The ENDFILE(X) could be used in loops to test whether the end of the file was reached during reads. [42]

The system also included a function TEL that returned whether or not there was input waiting in the terminal. SUPER BASIC programs often included code like

100WAIT(1);IFNOTTELTHEN100

to wait for user input and test it every second before continuing. [43] Additionally, it included a pseudo-filename "TEL" that could be opened for reading and writing using OPEN"TEL"FOROUTPUTAS2 and then WRITEON2"HELLO WORLD". [44] In addition to "TEL", both "T" and "TELETYPE" also referenced the command teletype. [45]

Notes

  1. The terminology originates with JOSS, MS-derived BASICs generally refer to this as "immediate mode" instead.
  2. Hexadecimal did not become popular until most machines used 8-bit based words, in the era of 6-bit bases like the SDS 940, octal was common.

Related Research Articles

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with the Apple II series of computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC because of the Apple DOS command used to invoke it, instead of INT for Integer BASIC.

<span class="mw-page-title-main">JOSS</span> Interactive programming language

JOSS was one of the first interactive, time-sharing programming languages. It pioneered many features that would become common in languages from the 1960s into the 1980s, including use of line numbers as both editing instructions and targets for branches, statements predicated by boolean decisions, and a built-in source-code editor that can perform instructions in direct or immediate mode, what they termed a conversational user interface.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays, for example.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

Dartmouth BASIC is the original version of the BASIC programming language. It was designed by two professors at Dartmouth College, John G. Kemeny and Thomas E. Kurtz. With the underlying Dartmouth Time Sharing System (DTSS), it offered an interactive programming environment to all undergraduates as well as the larger university community.

In computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.

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.

bc, for basic calculator, is "an arbitrary-precision calculator language" with syntax similar to the C programming language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.

FOCAL is an interactive interpreted programming language based on JOSS and mostly used on Digital Equipment Corporation (DEC) Programmed Data Processor (PDP) series machines.

<span class="mw-page-title-main">Vilnius BASIC</span> Dialect of the BASIC programming language

Vilnius BASIC, sometimes known as BK BASIC, is a dialect of the BASIC programming language running on the Elektronika BK-0010-01/BK-0011M and UKNC computers. It was developed at Vilnius University, located in Lithuania which was a republic of the Soviet Union at the time.

CAL, short for Conversational Algebraic Language, was a programming language and system designed and developed by Butler Lampson at Berkeley in 1967 for the SDS 940 mainframe computer. CAL is a version of the seminal JOSS language with several cleanups and new features to take advantage of the SDS platform.

HP Time-Shared BASIC is a BASIC programming language interpreter for Hewlett-Packard's HP 2000 line of minicomputer-based time-sharing computer systems. TSB is historically notable as the platform that released the first public versions of the game Star Trek.

SCELBAL, short for SCientific ELementary BAsic Language, is a version of the BASIC programming language released in 1976 for the SCELBI and other early Intel 8008 and 8080-based microcomputers like the Mark-8. Later add-ons to the language included an extended math package and string handling. The original version required 8 kB of RAM, while the additions demanded at least 12 kB.

Data General Extended BASIC, also widely known as Nova Extended BASIC, was a BASIC programming language interpreter for the Data General Nova series minicomputers. It was based on the seminal Dartmouth BASIC, including the Fifth Edition's string variables and powerful MAT commands for matrix manipulation. In contrast to the compile-and-go Dartmouth BASIC, Extended BASIC was an interpreter.

The TENET 210 was a mainframe computer designed for timesharing services. The machine was designed for high throughput and expandability, including 20 direct memory access (DMA) channels and eight slots for core memory, allowing up to 128k 32-bit words of RAM. The sales materials boasted that it guaranteed user responses within one second.

SDS BASIC, also known as CP-V BASIC, Batch BASIC or Sigma BASIC depending on the version, is a BASIC programming language compiler for Scientific Data Systems's (SDS) Sigma series mainframe computers, originally released in 1967. Xerox purchased SDS in 1969 and began rebranding it as Xerox Data Systems, and finally just Xerox, at which time the language became known as Xerox BASIC.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

Wang BASIC is a series of BASIC programming languages for computers from Wang Laboratories. The term can be used to refer to the BASIC on any Wang machine, but is mostly associated with the versions on the Wang 2200 minicomputer series of the early 1970s. When these machines were updated to the VP series in 1976, BASIC-2 was introduced and remained the pattern for future machines in the 2200 series. A planned BASIC-3 was never released.

CALL/360:BASIC was an IBM dialect of the BASIC programming language for the System/360 and later platforms. It was based on mid-1960s versions of Dartmouth BASIC but added a number of extensions. Most of these were related to file handling, which, at that time, Dartmouth lacked. It also added support for the mathematical symbols found on some IBM terminals, so that <= could be entered directly as . Differences are otherwise minor.

Acorn System BASIC and Atom BASIC are two closely related dialects of the BASIC programming language developed by Acorn Computers for their early microcomputers like the Acorn System 3 and Acorn Atom. Developed in-house, they have a number of significant idiosyncrasies compared to most BASIC dialects of the home computer era.

References

Citations

  1. Lampson, Butler, "Systems", Research, Microsoft
  2. 1 2 Gregory 2018, p. 132.
  3. 1 2 3 4 Gregory 2018, p. 133.
  4. 1 2 Manual 1978, p. 14.
  5. Manual 1978, p. 3.
  6. Manual 1978, p. 11.
  7. Manual 1978, p. 107.
  8. Manual 1978, p. 13.
  9. Manual 1978, p. 15.
  10. Manual 1978, p. 143.
  11. Manual 1978, p. 9.
  12. 1 2 Manual 1978, p. 43.
  13. Manual 1978, p. 140.
  14. 1 2 3 Manual 1978, p. 29.
  15. Manual 1978, p. 44.
  16. Manual 1978, p. 45.
  17. 1 2 3 Manual 1978, p. 47.
  18. Manual 1978, pp. 6, 7.
  19. Manual 1978, p. 26.
  20. Manual 1978, p. 27.
  21. Manual 1978, p. 25.
  22. 1 2 Manual 1978, pp. 7, 8.
  23. Manual 1978, p. 17.
  24. 1 2 Manual 1978, p. 21.
  25. Manual 1978, p. 24.
  26. Manual 1978, p. 30.
  27. Manual 1978, pp. 30, 31.
  28. Manual 1978, p. 28.
  29. Manual 1978, p. 33.
  30. Manual 1978, p. 34.
  31. Manual 1978, pp. 35–37.
  32. Manual 1978, p. 18.
  33. Manual 1978, p. 51.
  34. Manual 1978, p. 52.
  35. Manual 1978, p. 53.
  36. Manual 1978, p. 55.
  37. Manual 1978, p. 60.
  38. Manual 1978, pp. 71–75.
  39. Manual 1978, p. 84.
  40. Manual 1978, p. 85.
  41. Manual 1978, p. 132.
  42. Manual 1978, p. 126.
  43. Manual 1978, p. 99.
  44. Manual 1978, p. 76.
  45. Manual 1978, p. 89.

Bibliography