This articlerelies largely or entirely on asingle source. Relevant discussion may be found on thetalk page. Please helpimprove this article byintroducing citations to additional sources. Find sources: "Southampton BASIC System" – news ·newspapers ·books ·scholar ·JSTOR(December 2023) |
Southampton BASIC System (SOBS) was a dialect of theBASICprogramming language developed for and used onICT 1900 series computers in the late 1960s and early 1970s; it was implemented as an incrementalBASIC interpreter under theMINIMOP operating system at theUniversity of Southampton[1] and also ran underMAXIMOP.
It was operated from aTeletype terminal, though CRT terminals could also be used.
In common with many early implementations of BASIC, SOBS needed lines to haveline numbers, both to allow a user to add new lines to the program in the desired place and also as targets forGOTO andGOSUB statements. ARENUMBER facility was available to allow for sections of the code to be renumbered, by default in increments of 10, to allow more space in the middle of a program.
Other than line numbers, all numeric values were represented internally asfloating point.
The language had relatively few statements by comparison with modern programming languages:
| Statement | Purpose |
|---|---|
DATA | Stored data forREADing into variables at runtime |
DIMvar(size)... | Dimension an array. One-, two- and three-dimensional arrays were supported. |
END | Halt execution of the program. |
FORvar=start TOend [STEPincr] | Perform a set of statements repeatedly for varying values ofvar |
GOSUBline | Call a subroutine at a given line number; flow would return to the next statement when aRETURN was executed. |
GOTOline | Unconditional branch to a given line number. |
IFexpr THENline [ELSEline] | Conditionally branch. TheTHEN andELSE parts could only give line numbers to go to. |
INPUTvar | Prompt the user for input data |
LETvar=expr | Assign a value to a variable. Unlike many modern dialects of BASIC,LET was not an optional word. |
NEXTvar | Perform the next iteration of aFOR loop. |
PRINT | Output to the Teletype |
READvar... | Read data fromDATA statements into variables |
REM | Short forREMark, this allowed for a comment to be placed on a line |
RESTORE [line] | Reset theREAD pointer in order to re-readDATA |
RETURN | Return to the line following aGOSUB. |
Note in particular the lack of aWHILE-like statement;FOR was the only looping construct available to programmers.
Variable names for numeric values were either a single letter, or a single letter followed by a single numeric digit, thus allowing for 286 discreet variables in total. Strings were supported; variable names for them had the same restriction but were followed by a pound (£) symbol.
A limited number of numeric functions were provided, all of which took one numeric parameter:
| Function | Function() returned |
|---|---|
SIN | |
COS | |
ATN | |
SQR | |
LOG | |
EXP | |
INT | The largest integer not greater than |
SGN | −1, 0, or 1, depending on whether was less than, equal to, or greater than zero |
ABS | if was negative, otherwise |
Support for strings was more limited, with only one function,LEN, which returned the length of the string parameter. Sub-strings were supported with square brackets, soA£[2,3] referred to the sub-string of the stringA£ from the 2nd character to the 3rd character inclusive, so
10LETA£="FOO"20PRINTA£[2,3]
would printOO
This syntax was also supported on the left-hand side of an assignment, so
10LETA£="FOO"20LETA£[2,2]="BAR"30PRINTA£
would printFBARO
Support for handling arrays of data was relatively strong, withMAT statements able to read an entire array fromDATA statements, and perform usefulmatrix operations such asmatrix addition,matrix subtraction,matrix multiplication, and finding theinverse matrix for asquare matrix.
Example:
10DIMA(3,3)20MATREADA30DATA1,1,2,1,0,2,0,2,140DIMB(3,3)50MATREADB60DATA0,0,1,0,1,0,1,0,070DIMC(3,3),D(3,3)80MATC=A*B90MATD=INV(C)100MATPRINTD,
A is read from the firstDATA statement | |
B is read from the secondDATA statement | |
C is calculated by multiplyingA andB | |
D is calculated as the inverse ofC |
The output would be2 2 11 -1 04 -3 -2
This sectionneeds expansion. You can help byadding missing information.(May 2009) |
SOBS had primitive debugging capabilities, limited mostly to theTRACE statement.TRACE ON would cause the interpreter to print each line number as it was executed.