SuperBASIC


SuperBASIC is an advanced variant of the BASIC programming language with many structured programming additions. It was developed at Sinclair Research by Jan Jones during the early 1980s.
Originally SuperBASIC was intended as the BASIC interpreter for a home computer code-named SuperSpectrum, then under development. This project was later cancelled; however, SuperBASIC was subsequently included in the ROM firmware of the Sinclair QL microcomputer, also serving as the command line interpreter for the QL's QDOS operating system.
It was one of the first second-generation BASICs to be integrated into a microcomputer's operating system, making the OS user-extendable—as done by Linus Torvalds in his formative years.

Reception

BYTE in September 1984 approved of SuperBASIC's improvements over Sinclair BASIC but criticized its "very, very slow" performance on the Byte Sieve, writing that "With a 7.5-MHz 68008, you'd think it would take some effort to get a language to run that slowly". The magazine also noted that SuperBASIC's seven-digit precision made it unsuitable for business use.

Advanced features

  • RESPR for resident procedures, e.g. to extend QDOS
  • choice of parameters passed to procedures
  • procedures return parameters as chosen
  • IF - THEN - ELSE - END IF
  • FOR - NEXT - EXIT - END FOR
  • REPeat - NEXT - EXIT - END REPeat
  • SELect ON - ON - REMAINDER - END SELect
  • arbitrarily RETurn from within procedures & functions
  • data type coercion between numeric and string variables
  • actual parameters passing data type to formal parameters
  • array operations: slicing, joining etc.
  • LOCal arrays & variables
  • AUTOmatic line numbering
  • relative RESTORE & DATA
The function below illustrates the last eight of these features. After having RUN it, entering
PRINT weekdays$
will print FRI to the screen. Until cleared, the function will act like an extension to the operating system. Similarly, according to the QL User Guide, "many of the operating system commands are themselves defined as procedures."

Example

AUTO 11,2
DEFine FN Iso
LOCal y%,m%,d%,i$,n%,w%
REM Step 0 - to isolate components of date-stamp S="YEARMoDa"
LET y%=S : m%=S : d%=S
REM Step 1 - to initiate Lachman's Congruence
LET i$=m%*2.56+ 193 : S=S- 3
REM Step 2 - to compute the day-number within the week
LET w%=&"32"DIV 16+ SDIV 4+ y%+ i$MOD 7

REM Step 3 - to return result
SELect ON O
ON O= 5 : n%=i$
ON O= 4 : n%=y%
ON O= 3 : n%=m%
ON O= 2 : n%=d%
ON O= 1 : n%=w%
ON O= REMAINDER : n%=-1
END SELect
RETurn n%
REM data statements
DIM weekdays$
RESTORE 190
FOR count=0 TO 6 : READ weekdays$

100 DIM month$
110 RESTORE
120 REM QL User Guide's "Data Read Restore" example ii
130 REM appropriately amended relative to example i
140 FOR count=1 TO 12 : READ month$
150 DATA "January","February","March"
160 DATA "April","May","June"
170 DATA "July","August","September"
180 DATA "October","November","December"
190 DATA "SUN","MON","TUE","WED","THU","FRI","SAT"
199 END DEFine Iso