From Wikipedia, the free encyclopedia
  (Redirected from SuperBasic)
Jump to: navigation, search

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 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 (announced in January 1984), also serving as the command line interpreter for the QL's Qdos operating system. It is notable for being the first second-generation BASIC to be integrated into a microcomputer's operating system, so making the latter user-extendable--as exemplified by Linus Torvalds in his formative years.

Advanced Features[edit]

  • RESPR for resident procedures: e.g. to extend Qdos
  • choice of parameters passed to procedures
  • procedures return parameters as chosen
  • REPeat - NEXT - EXIT - END REPeat
  • arbitrarily RETurn within procedures & functions
  • data type coercion between numeric & string variables
  • actual parameters passing data type to formal parameters
  • array operations: slicing, joining etc.
  • LOCal arrays & (string) variables
  • AUTOmatic line numbering
  • relative RESTORE & DATA

The example below illustrates the last eight of these features. After entering the statements, entering

      RUN : PRINT weekdays$(Iso("19631122",1))

will print FRI to the screen. Until cleared (e.g. by entering NEW), the function Iso[1] 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."[2]


AUTO 11,2

  DEFine FN Iso(S,O)
  LOCal y%,m%,d%,i$,n%,w%

  REM Step 0 - to isolate components of a date Stamp "YEARMoDa"
  LET y%=S(1TO 4) : m%=S(5TO 6) : d%=S(7TO 8)

  REM Step 1 - to apply Lachman's Method of Congruence[3]
  LET i$=m%*2.56+ 193 : S=S(1TO 6)- 3

  REM Step 2 - to compute the day-number within the week
  LET w%=(S(1TO 2)&"32"DIV 16+ S(1TO 4)DIV 4+ y%+ i$(2TO 3)+ d%)MOD 7
  REM Step 3 - to return result
         SELect ON O
                ON O= 5 : n%=i$(2TO 3)
                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%

  REMark data statements
  DIM weekdays$(6,3)
  FOR count=0 TO 6 : READ weekdays$(count)


 100 DIM month$(12,9)
 120 REMark QL User Guide's "Data Read Restore" example ii
 130 REMark (appropriately amended relative to example i)
 140 FOR count=1 TO 12 : READ month$(count) 
 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


  • Donald Alcock: Illustrating Superbasic on the Sinclair QL. Cambridge University Press, 1985. ISBN 0-521-31517-4
  • Roy Atherton: Good Programming with QL Superbasic. Longman Software, 1984. ISBN 0-582-29662-5
  • A. A. Berk: QL SuperBasic. Granada Publishing, 1984. ISBN 0-246-12596-9
  • Jan Jones: QL SuperBasic: The Definitive Handbook. McGraw-Hill, 1984 ISBN 0070847843 (e-book reissue 2014)
  • Dick Meadows, Robin Bradbeer, Nigel Searle: Introduction to Superbasic on the Sinclair QL. Hutchinson Computer Publishing, 1984. ISBN 0-09-158951-7
  • Dick Meadows, Robin Bradbeer, Nigel Searle: Making the Most of the Sinclair QL: QL Superbasic and Its Applications. Hutchinson Computer Publishing, 1985. ISBN 0-09-160561-X
  • Andrew Nelson: Exploring the Sinclair QL: An Introduction to SuperBasic. Interface Publications, 1984. ISBN 0-907563-84-8
  • John K. Wilson: QL Superbasic: A Programmer's Guide. Micro Press, 1984. ISBN 0-7447-0020-5


  1. ^ gopher://
  2. ^ Sinclair Research Ltd. QL User Guide, 2nd Ed. Cambridge: (1984). Keywords, "DEFine PROCedure"
  3. ^ Motorola 68000#Example code
  4. ^ "Illustrating Superbasic on the Sinclair QL - World of Spectrum". Retrieved 2016-04-11. 

External links[edit]