Southampton BASIC System: Difference between revisions

Content deleted Content added
Initial content
 
Line 16:
 
It was operated from a [[teletype]] terminal.
 
== 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>END</code>
| Halt execution of the program.
|-
| <code>GOSUB</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</code>
| Unconditional branch to a given line number.
|-
| <code>IF...THEN...ELSE</code>
| Conditionally branch. The <code>THEN</code> and <code>ELSE</code> parts could only give line numbers to go to.
|-
| <code>INPUT</code>
| Prompt the user for input data
|-
| <code>LET</code>
| Assign a value to a variable. Unlike many modern dialects of BASIC, <code>LET</code> not an optional word.
|-
| <code>PRINT</code>
| Output to the teletype
|-
| <code>READ</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</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>.
|}
 
=== 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>&pound;</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>SGN</code>
| &minus;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. This syntax was also supported on the left-hand side of an assignment, so
LET A£ = "FOO"
LET A£[2,2] = "BAR"
PRINT A£
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 arithmetic operations such as adding or multiplying two arrays, or even finding the [[multiplicative inverse]] of a [[square matrix]].
 
== Debugging ==
{{expand-section|date=May 2009}}
SOBS had primitive debugging capabilities, limited mostly to the <code>TRACE</code> statement.
 
==References==
{{Reflist}}
 
{{Programming-software-stub}}
{{ICL hardware}}
[[Category:BASIC programming language family]]