Content deleted Content added
Initial content |
m Open access bot: url-access updated in citation with #oabot. |
||
(43 intermediate revisions by 22 users not shown) | |||
Line 1:
{{One source|date=December 2023}}
{{see also|SOB (disambiguation)}}
{{Use dmy dates|date=August 2021}}
'''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]]<ref>
{{cite journal
| last1 = Rees
| first1 = M.J.
| last2 = Oppenheimer
| first2 = A.W.
| title = SOBS
|
| publisher = Wiley InterScience
| date =
| volume = 7
| issue = 5
| pages = 631–643
| url = http://www3.interscience.wiley.com/journal/113444749/abstract?CRETRY=1&SRETRY=0
| archive-url = https://archive.today/20130105083634/http://www3.interscience.wiley.com/journal/113444749/abstract?CRETRY=1&SRETRY=0
| url-status = dead
| archive-date = 5 January 2013
| format =
| doi = 10.1002/spe.4380070508
| s2cid = 33989728
| access-date = 18 May 2009
| url-access = subscription
}}</ref> and also ran under [[MAXIMOP]].
It was operated from a [[
== Language characteristics ==
In common with many early implementations of BASIC, SOBS needed lines to have [[line number]]s, both to allow a user to add new lines to the program in the desired place and also as targets for <code>GOTO</code> and <code>GOSUB</code> statements. A <code>RENUMBER</code> 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 as [[floating point]].
=== Statements ===
The language had relatively few statements by comparison with modern programming languages:
{| class="wikitable"
|-
! Statement
! Purpose
|-
| <code>DATA</code>
| Stored data for <code>READ</code>ing into variables at runtime
|-
| <code>DIM ''var''(''size'')...</code>
| Dimension an array. One-, two- and three-dimensional arrays were supported.
|-
| <code>END</code>
| Halt execution of the program.
|-
| <code>FOR ''var''=''start'' TO ''end'' [STEP ''incr'']</code>
| Perform a set of statements repeatedly for varying values of ''var''
|-
| <code>GOSUB ''line''</code>
| Call a subroutine at a given line number; flow would return to the next statement when a <code>RETURN</code> was executed.
|-
| <code>GOTO ''line''</code>
| Unconditional branch to a given line number.
|-
| <code>IF ''expr'' THEN ''line'' [ELSE ''line'']</code>
| Conditionally branch. The <code>THEN</code> and <code>ELSE</code> parts could only give line numbers to go to.
|-
| <code>INPUT ''var''</code>
| Prompt the user for input data
|-
| <code>LET ''var''=''expr''</code>
| Assign a value to a variable. Unlike many modern dialects of BASIC, <code>LET</code> was not an optional word.
|-
| <code>NEXT ''var''</code>
| Perform the next iteration of a <code>FOR</code> loop.
|-
| <code>PRINT</code>
| Output to the Teletype
|-
| <code>READ ''var''...</code>
| Read data from <code>DATA</code> statements into variables
|-
| <code>REM</code>
| Short for <code>REM</code>ark, this allowed for a comment to be placed on a line
|-
| <code>RESTORE [''line'']</code>
| Reset the <code>READ</code> pointer in order to re-read <code>DATA</code>
|-
| <code>RETURN</code>
| Return to the line following a <code>GOSUB</code>.
|}
Note in particular the lack of a <code>WHILE</code>-like statement; <code>FOR</code> was the only looping construct available to programmers.
=== Variables ===
[[Variable (programming)|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 (<code>£</code>) symbol.
=== Functions ===
A limited number of numeric functions were provided, all of which took one numeric parameter:
{| class="wikitable"
|-
! Function
! Function(<math>x</math>) returned
|-
| <code>SIN</code>
| <math>\sin x</math>
|-
| <code>COS</code>
| <math>\cos x</math>
|-
| <code>ATN</code>
| <math>\arctan x</math>
|-
| <code>SQR</code>
| <math>\sqrt{x}</math>
|-
| <code>LOG</code>
| <math>\log x</math>
|-
| <code>EXP</code>
| <math>e^x</math>
|-
| <code>INT</code>
| The largest integer not greater than <math>x</math>
|-
| <code>SGN</code>
| −1, 0, or 1, depending on whether <math>x</math> was less than, equal to, or greater than zero
|-
| <code>ABS</code>
| <math>-x</math> if <math>x</math> was negative, otherwise <math>x</math>
|}
Support for strings was more limited, with only one function, <code>LEN</code>, which returned the length of the string parameter. Sub-strings were supported with square brackets, so <code>A£[2,3]</code> referred to the sub-string of the string <code>A£</code> from the 2nd character to the 3rd character inclusive, so
<syntaxhighlight lang="basic">
10 LET A£ = "FOO"
20 PRINT A£[2,3]
</syntaxhighlight>
would print <code>OO</code>
This syntax was also supported on the left-hand side of an assignment, so
<syntaxhighlight lang="basic">
10 LET A£ = "FOO"
20 LET A£[2,2] = "BAR"
30 PRINT A£
</syntaxhighlight>
would print <code>FBARO</code>
=== Arrays ===
Support for handling arrays of data was relatively strong, with <code>MAT</code> statements able to read an entire array from <code>DATA</code> statements, and perform useful [[matrix (mathematics)|matrix]] operations such as [[matrix addition]], [[matrix subtraction]], [[matrix multiplication]], and finding the [[inverse matrix]] for a [[square matrix]].
Example:
<syntaxhighlight lang="basic">
10 DIM A(3,3)
20 MAT READ A
30 DATA 1,1,2,1,0,2,0,2,1
40 DIM B(3,3)
50 MAT READ B
60 DATA 0,0,1,0,1,0,1,0,0
70 DIM C(3,3),D(3,3)
80 MAT C=A*B
90 MAT D=INV(C)
100 MAT PRINT D,
</syntaxhighlight>
{|
|<code>A</code> is read from the first <code>DATA</code> statement
|<math>\begin{pmatrix}
1 & 1 & 2 \\
1 & 0 & 2 \\
0 & 2 & 1
\end{pmatrix}</math>
|-
|<code>B</code> is read from the second <code>DATA</code> statement
|<math>\begin{pmatrix}
0 & 0 & 1 \\
0 & 1 & 0 \\
1 & 0 & 0
\end{pmatrix}</math>
|-
|<code>C</code> is calculated by multiplying <code>A</code> and <code>B</code>
|<math>\begin{pmatrix}
2 & 1 & 1 \\
2 & 0 & 1 \\
1 & 2 & 0
\end{pmatrix}</math>
|-
|<code>D</code> is calculated as the inverse of <code>C</code>
|<math>\begin{pmatrix}
2 & 2 & 1 \\
1 & -1 & 0 \\
4 & -3 & -2
\end{pmatrix}</math>
|}
The output would be
2 2 1
1 -1 0
4 -3 -2
== Debugging ==
{{expand section|date=May 2009}}
SOBS had primitive debugging capabilities, limited mostly to the <code>TRACE</code> statement. <code>TRACE ON</code> would cause the interpreter to print each line number as it was executed.
==References==
{{Reflist}}
{{BASIC}}
{{DEFAULTSORT:Southampton Basic System}}
[[Category:BASIC interpreters]]
[[Category:ICL programming languages]]
[[Category:Science and technology in Hampshire]]
[[Category:University of Southampton]]
[[Category:BASIC programming language family]]
|