SDS BASIC

Last updated
SDS BASIC
Paradigm imperative
First appeared1967;56 years ago (1967)
OS several
Influenced by
Dartmouth BASIC
Influenced
HP Time-Sharing BASIC, SCELBAL many others

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.

Contents

The original versions did not include support for string variables, although this was added for the version running under the CP-V operating system when it was released in 1971. The string library allowed manipulation of strings using array slicing syntax, similar to the system found in HP Time-Shared BASIC and a number of microcomputer BASICs like Integer BASIC and Atari BASIC.

This style of string manipulation differs from the model introduced in DEC's BASIC-PLUS, which used string functions. Altair BASIC was patterned on BASIC-PLUS, and this style became the de facto standard after the cross-platform version, Microsoft BASIC, became almost universal during the home computer era. This makes conversion from SDS to modern dialects somewhat difficult.

SDS BASIC is historically notable as the platform on which the original Star Trek computer game was written in the summer of 1971. [1]

Syntax

In keeping with the original Dartmouth BASIC model, and in common with most mainframe-based BASICs, SDS BASIC was a compiler, not an interpreter, and used separate but tightly integrated tools for editing and running. The editor was dedicated to BASIC; as lines are entered they are analyzed for correct syntax and then stored in tokenized form. If a line is entered with a number at the start, it is placed into the appropriate location in the program based on the number, lines without numbers were immediately processed and then forgotten. SDS allowed line numbers in the range 1 to 99999. [2] A simple example is:

10PRINT"HELLO WORLD"

Like many versions of BASIC, SDS allowed a single line of code to contain multiple statements. In most dialects this is indicated using the colon, but SDS used either the backslash, \ or ampersand, &. [3] An equivalent line in SDS would be:

10PRINT"HELLO"\PRINT"WORLD"

Because SDS was a compiler, and the user's source code was stored separately, it preserved leading spaces in the code. They suggested using this to more clearly indicate the structure of loops: [4]

10LETJ=0,K=120FORI=KTO830PRINTJ40M=J,J=K,K=K+150NEXTI

This example also includes the ability to set multiple values in a single LET statement, as seen in lines 10 and 40. This feature was also found in HP BASIC. As in most versions of BASIC, the keyword LET is optional, and is left out of line 40. Line 40 also illustrates the alternate form of assignment seen in a number of early BASICs, where multiple assignments can be separated with commas. [5]

Common mathematical operations included +, -, * and /, using ^ or ** for exponents. [2] Logical comparisons, like HP, could be written in any order, so <= was equivalent to =<, and >< was the same as <>. [3] Most dialects only allow the later syntax in both cases. Unlike HP BASIC, SDS did not include the ability to use the hash, #, as an alternate form of <>.

SDS supported computed GOTO using ON, but also allowed the alternate syntax with the ON at the end of the line instead of the front:

GOTO140,160,180ONY

An alternate form of REM was a leading star, *, [6] similar in purpose to the short-form found in MS-derived BASICs, the single quote, '. [7]

String handling

The early versions of SDS BASIC, sometimes known as Batch BASIC or BTM BASIC, did not support string variables. However, string values could be assigned to numeric variables which could store six characters as their EBCDIC numeric values. [8] The later CP-V BASIC added true string variables containing up to 132 characters that could be indicated with a trailing dollar sign, $, or uncommonly, a leading $ A$ and $A are equivalent. The manual notes that the latter format was added for compatibility with A00 BASIC. [9] [lower-alpha 1]

Internally, CP-V used a fixed-length string layout consisting of an array of bytes that could not be changed in size at runtime. This was similar to the other BASICs that used slicing notation, like HP and Atari. It contrasts with the DEC/Microsoft style, where strings were dynamically allocated on a heap. Unlike the other fixed-length BASIC dialects, string variables did not have to be DIMmed prior to use, instead, all strings defaulted to a maximum length of 72 characters. This was a global setting that could be changed to better manage memory by setting it to a smaller value, or allow longer strings up to a maximum of 132 characters. This was accomplished using SET $=132. Confusingly, SET was also used for the entirely unrelated task of allowing variables to be used in DIM statements. [10]

Because strings in CP-V did not present themselves publicly as arrays of characters, the slicing syntax was not based on array syntax. This meant CP-V also allowed the construction of arrays of strings, something dialects like HP and Atari lacked because they used array notation for slicing. One could thus make a matrix of strings using DIM: [9]

10DIMA$(5,10)

would define a matrix containing a total of 50 72-character strings in a 5 by 10 matrix. Because the system supported arrays, slicing syntax was somewhat more complex than the system found in other versions. Examples include: [9]

A$(1)

selects the first string in an array of strings, while:

A$(1,5)

selects a string from location 1,5 in a 2D array (matrix). Slicing was handled by adding a colon within the parens: [9]

A$(:4)

returned everything from the 4th character on:

A$(:4,5)

selects five characters starting with the 4th character, while:

A$(1,5:4,5)

selects five characters starting with the 4th character of the string in locations 1,5 in a 2D array. [9]

String constants could be delimited with either single or double quotes, making it easier to enclose quotes within lines. Valid examples include: [11]

PRINT'THIS IS A STRING LITERAL'PRINT"THIS IS ANOTHER ONE"PRINT'AND THIS IS "A THIRD"'PRINT"AND 'A FOURTH'"

CP-V also includes the CHANGE command from Dartmouth BASIC, which converts a string into a series of EBCDIC numeric values and places them into a numeric array: [12]

10DIMB(6)20CHANGE"ABCDEF"TOB

B will now contain a series of numbers corresponding to the EBCDIC values for each character. [12]

Input/output

SDS included a robust system for input/output based on "stream" numbers that could be specified in PRINT and INPUT statements. For instance, data could be read from a file using:

10OPEN'FILE1' TO :1,INPUT20INPUT:1,A

The first line opens a disk file with the name "FILE1", assigns it to stream 1, and indicates it will be used for input. The second line reads the next data from stream 1, in this case the first value, and assigns the resulting data to variable A. The system also included a unique "key" system that allowed data to be numbered and then accessed randomly. This was accomplished by adding the key number after a semicolon:

INPUT:1;9999,A

will attempt to read record 9999. Valid keys were in the range .001 to 9999.999, and if no keys were assigned in the files, lines were assigned numbers 1.000, 2.000, etc. The highest-valued key in a file could read using: [13]

KEY(1)

where the 1 is the stream number. [13] Unstructured binary data could be read and written byte-at-a-time using GET and PUT. [14]

MAT commands

Later versions of Dartmouth BASIC included a suite of MAT commands that allowed operations on entire arrays (matrices) with a single statement. These were also available in SDS BASIC. In their simplest form, the MAT is used like an alternate form of LET, applying an expression to all the elements in an array. For instance:

100DIMA(20),B(20)...200MATA=A+B

Will add the value of every value in B to every entry in A, in the same fashion as:

100DIMA(20),B(20)...200FORI=1TO20210A(I)=A(I)+B(I)220NEXTI

As well as making the code shorter and more obvious, these commands also have the advantage of being highly optimized, easily outperforming the use of FOR/NEXT. [15] Additional functions and statements modify PRINT and INPUT, invert arrays, and build identity matrixes and such in a single statement. [16]

Notes

  1. A00 appears to be another name for Batch BASIC, where the leading $ was a macro for converting the values to EBCDIC.

Related Research Articles

<span class="mw-page-title-main">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

<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.

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.

In computer programming, array slicing is an operation that extracts a subset of elements from an array and packages them as another array, possibly in a different dimension from the original.

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.

IBM System/34 BASIC was an interpreter for the IBM System/34 midrange computer.

IBM System/36 BASIC was an interpreter for the IBM System/36 midrange computer.

<span class="mw-page-title-main">FutureBASIC</span>

FutureBasic is a free BASIC compiler for Apple Inc.'s Macintosh.

Southampton BASIC System (SOBS) was a dialect of the BASIC programming language developed for and used on ICT 1900 series computers in the late 1960s and early 1970s; it was implemented as an incremental BASIC interpreter under the MINIMOP operating system at the University of Southampton and also ran under MAXIMOP.

North Star BASIC was a dialect of the BASIC programming language for the Intel 8080 microprocessor used on the North Star Horizon and available for purchase on other S-100 bus machines of the late 1970s.

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.

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.

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.

SNAP, short for Stylized, Natural, Procedural, is an educational programming language designed by Michael Barnett while working at RCA in 1968 and later used at Columbia University to teach programming in the humanities. It is an imperative programming language, like many languages of the 1960s, but was deliberately verbose, attempting to look more like conversational English in the fashion of HyperText and later languages. Unlike other educational languages of the era, SNAP was not intended to be interactive and was designed to be programmed via punch cards. To save cards, multiple period-separated statements could be written on every card, so the resulting code often looked like a single paragraph.

<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.

Full BASIC, sometimes known as Standard BASIC or ANSI BASIC, is an international standard defining a dialect of the BASIC programming language. It was developed by the American National Standards Institute (ANSI) X3.60 group in partnership with the European ECMA. It describes an advanced version of BASIC with many features including structured programming, matrix math, input/output for file handling, and many other options.

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. Markowitz, Maury; Mayfield, Mike (2000). "Star Trek". Games of Fame. Archived from the original on 2018-11-06. Retrieved 2018-11-27.
  2. 1 2 Xerox 1974, p. 2.
  3. 1 2 Xerox 1974, p. 19.
  4. Xerox 1974, p. 3.
  5. Xerox 1974, p. 9.
  6. Xerox 1974, p. 17.
  7. "REM Statement (Visual Basic)". Microsoft. 20 July 2015.
  8. Xerox 1974, p. 23.
  9. 1 2 3 4 5 Xerox 1974, p. 21.
  10. Xerox 1974, p. 40.
  11. Xerox 1974, p. 8.
  12. 1 2 Xerox 1974, p. 25.
  13. 1 2 Xerox 1974, p. 26.
  14. Xerox 1974, p. 29.
  15. Ref 1976, p. 11-50.
  16. Xerox 1974, p. 34.

Bibliography