HP Time-Shared BASIC

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
HP Time-Shared BASIC
Paradigm imperative
First appeared before 1969; 49 years ago (1969)
OS HP 2100
Influenced by
Dartmouth BASIC
Influenced
Cf. Integer BASIC

HP Time-Shared BASIC (HP TSB) is an interpreter software system that was sold by the Hewlett-Packard Company in the late 1960s and 1970s, based on their HP 2100 line of minicomputers. The system implements a dialect of the BASIC programming language and a rudimentary user account and program library system. The system is historically notable as the platform that released the first public versions of the game Star Trek.

The software was also known by its versioned name, tied to the hardware version on which it ran, such as HP 2000C Time-Shared BASIC and the operating system came in different varieties — 2000A, 2000B, 2000C, High-Speed 2000C, 2000E, 2000F, and 2000/Access. Except for the 2000A and 2000E systems, the system is implemented using a dual-processor architecture. One fully configured HP 2100-series processor is used for execution of most of the system code and all of the user code, while a second, smaller HP 2100-series processor is used to handle the RS-232 serial lines through which the time-sharing users connected. Depending on the hardware configuration, the system supports up to 16 or up to 32 simultaneous remote users.

The usual terminal for a TSB system was a Teletype Model 33 ASR and connected directly to the I/O processor or through a modem or acoustic coupler. Account names are a combination of one alphabetic character, followed by three decimal digits, e.g., B001. Privileged accounts started with the letter "A" and had some additional command and program storage capabilities. The superuser account is A000. This scheme allows up to 26,000 user accounts. (In the offshoot system created by BTI Computer Systems accounts beginning with "@" were superuser accounts.)[citation needed]

During execution, user programs are swapped to fixed-head hard drive (which was physically a disk, but operated like a magnetic drum). When not executing, user programs are stored on moving-head cartridge- or pack-loaded disk storage. Privileged users can also store programs on the much-faster drum. The hard drive was backed up to magnetic tape.

Program and file names consist of a mix of up to six alphabetic characters (A-Z) and numbers (0-9). Programs are stored in a tokenized format, using the SAVE command. They can also be stored in a semi-compiled format, using the CSAVE command, which allows them to start quicker. Since the system was closely tied to the use of commonly available teleprinters, line endings in files consisted of the carriage return character (ASCII CR, 0D hexadecimal), followed by the linefeed character (ASCII LF, 0A hexadecimal).

The language is a fairly standard implementation of BASIC, providing an integrated editing and runtime environment. Statements are analyzed for correct syntax as they are entered and then stored in tokenized form. Each BASIC statement has to be on a uniquely numbered line, e.g., 10 PRINT "HELLO WORLD" and can only contain one statement, although multiple variable assignments are allowed, e.g., 20 LET A=B=C=42 (use of the word "LET" was optional). Line numbers are mandatory and statements are automatically placed in ascending numeric sequence.

In the earliest version (2000A), the language supported the following features.[1] Later versions added many more features.[2]

  • Unconditional program flow-control via GOTO statements, and subroutines via the GOSUB and RETURN statements
  • Conditional flow-control via IF/THEN statement and simple variable-based block loop FOR and NEXT statements
  • Calculated flow-control via the GOTO/OF and GOSUB/OF statements
  • In-code data storage via DATA, READ, and RESTORE statements
  • Input from and output to the user or a disc file via INPUT, READ #, PRINT, PRINT #, and IF END # statements
  • Numeric variables of the form "A" or "An" (where A is a single letter and n a single, optional digit) stored as 32-bit floating-point numbers
  • String variables of the form "A$" (where A is a single letter), storing from 0 to 72 characters
  • One- or two-dimensional matrix (array) variables of the form "A[x]" or "A[x,y]"
  • Matrix operations via statements (MAT READ, MAT INPUT, MAT PRINT, MAT=) and operations (+, -, *, ZER, CON, IDN, INV, TRN)
  • Boolean operators (AND, OR, NOT) and relational operators (<, <=, =, #, <>, >=, and >)
  • Built-in mathematical functions including trigonometric (SIN, COS, TAN, ATN), logarithms (LOG, EXP), square root (SQR), random number generator (RND), others (ABS, INT, SGN, MIN, MAX), and user-defined functions
  • Punched tape operations using Teletype Model 33 electromechanical teleprinter remote terminals

Substrings within strings are accessed using a substring notation: "A$(L,R)" or "A$[L,R]", where the substring begins with the leftmost character specified by the index L and continues to the rightmost character specified by the index R, "A$[L]" where the substring starts at the leftmost character specified by the index L and continues to the end of the string. (TSB accepts () or [] interchangeably.) This is in sharp contrast to some later microcomputer BASICs that use functions such as LEFT$(), MID$(), and RIGHT$() to access substrings, although ANSI BASIC continues to use a similar substring syntax to that introduced by Hewlett-Packard. HP's notation can also be used on the destination side of a LET or INPUT statement to modify part of an existing string value, for example 100 A$[3,5]="XYZ" or 120 B$[3]="CHANGE ALL BUT FIRST TWO CHARS", which cannot be done with early implementations of LEFT/MID/RIGHT$().

Array and substring indices start with 1. Boolean and relational operators can be used in any mathematical expression (giving 0 for false or 1 for true), which was unusual for BASIC languages of that time, but became very popular in languages like C.

Differences from Dartmouth BASIC included the use of square brackets for arrays and # for <>.

See also[edit]

References[edit]

  1. ^ HP 2000A - User's Guide, August 1969 Part Number 02000-90002, [1]. Retrieved 2016-05-09
  2. ^ HP 2000/Access BASIC - Reference Manual Part No. 22687-90001, [2]. Retrieved 2016-05-09
Notes
  • The Hewlett Packard Company (May 1976). HP 2000/Access BASIC Reference Manual, Part No. 22687-90001
  • The Hewlett Packard Company (May 1976). Learning Timeshare BASIC

External links[edit]