RTR logo


Introduction and Overview

Introduction to BBC BASIC

BBC BASIC is the programming language originally specified and adopted by the British Broadcasting Corporation for its groundbreaking Computer Literacy Project of the early 1980s. It was designed to be simple enough to be used by a complete beginner yet powerful enough to cope with the demands of the very largest and most complex programs, and that remains true today. During the intervening years BBC BASIC has been extended and ported onto at least seven different CPUs and more than thirty different platforms.

BBC BASIC for SDL 2.0 is an advanced cross-platform version of BBC BASIC which will run in Windows, MacOS, Linux (x86), Raspbian (Raspberry Pi), Android, iOS and in a browser. It combines the simplicity of BASIC with the sophistication of a modern structured language, allowing you to write utilities and games, use sound and graphics, perform calculations and create complete applications.

Getting Started

If you have never programmed in BASIC before, or you're so rusty that you feel the need for a refresher course, consider working through the Beginners' Tutorial which you can find either via the Help Menu or here.

If you've programmed in BASIC before, but aren't familiar with BBC BASIC, then you might like to dip into some of the tutorial chapters which cover differences between BBC BASIC and other dialects. You can also browse this manual or look up particular features which don't seem to work the way you're used to. The General Information chapter may be of particular interest.

If you are used to earlier versions of BBC BASIC (on the BBC Micro, on the Acorn Archimedes or BBC BASIC (86) on a PC) you may find the user interface somewhat unfamiliar. When you first start BBC BASIC for SDL 2.0 (desktop editions) you will be asked to choose one of the two supplied IDEs (Integrated Development Environments). These provide similar capabilities but are significantly different in their detailed interface, so you may want to experiment with both to discover which you prefer.

In both cases you will be presented with a blank editing window into which you can type your BASIC program. Commands such as Load, Save, Chain, New and Renumber are activated by clicking with the mouse on drop-down menus or (in some cases) toolbar buttons, as is usual for GUI programs. There are also keyboard shortcuts for all the commands.

Once you have typed in, or loaded, your BASIC program you can run it by selecting the Run command from the Run menu or by clicking on the Run button button in the toolbar. A second window will open in which appears any output from the BASIC program; error messages also appear here.

If you don't want to run a BASIC program, but simply want to enter commands for immediate execution (rather like a calculator) then select the Immediate Mode command from the Run menu, or click on the Immediate button. A second window will open into which you can type BASIC statements, in the same way as you could with previous versions of BBC BASIC.


BBC BASIC for SDL 2.0 has a Graphical User Interface, including a BASIC program editor with syntax colouring, live indentation, search & replace and many other features. Built-in diagnostic aids such as run-time trace, listing of variables and single-step execution make debugging even the most complex programs straightforward.

A unique feature is the incorporation of an assembler which generates code appropriate to the host platform (32-bit x86, 64-bit x86, 32-bit ARM or 64-bit ARM); the iOS and in-browser editions are exceptions and do not have an assembler. You can access the SDL 2.0 Application Program Interface both from BASIC and from assembler code, allowing an experienced programmer to produce sophisticated applications.

The desktop editions allow you to create a stand-alone application bundle from a BASIC program, which will run without BBC BASIC having to be installed. You can distribute such applications freely without any royalty being due.

BBC BASIC for SDL 2.0 is largely compatible with Version 5 of BBC BASIC resident in the Acorn Archimedes and Iyonix computers. It also retains a high degree of compatibility with the BBC Microcomputer, including emulation of the SOUND and ENVELOPE statements, and the MODE 7 (teletext) screen mode.

In addition there are a number of major enhancements over these early versions, including data structures, an EXIT statement, PRIVATE variables, long strings, NUL-terminated strings, event interrupts, an address of operator, byte variables and arrays, a line continuation character, indirect procedure and function calls and improved numeric accuracy.

Minimum system requirements

In order to be able to install and run BBC BASIC for SDL 2.0 your system must meet these minimum requirements:
WindowsWindows Vista or later, 32-bits or 64-bits.
Mac OSOS-X 10.6 (Snow Leopard) or later, x86 CPU, 64-bits only.
Linuxx86 CPU, 32-bits or 64-bits (glibc 2.27 or later).
RaspbianRaspberry Pi 2 or later (RPi 3 or 4 preferred), 32-bits only.
AndroidAndroid 4.4 (KitKat) or later.
iOSiPod 6th gen, iPhone 5S, iPad Air, iPad Mini 2 or later (64-bits).
In-browserMost desktop browsers (except IE and Safari), Chrome on Android.


BBC BASIC for SDL 2.0 meets or exceeds the following specification:
x86 platformsARM or in-browser platforms
Memory available for user's program, data and stack Default approximately 2 Mbytes, maximum 256 Mbytes Default approximately 2 Mbytes, maximum 256 Mbytes (16 Mbytes for the in-browser edition)
Size of BASIC programLimited only by available memory (maximum 65535 numbered lines) Limited only by available memory (maximum 65535 numbered lines)
Length of program linesMaximum 251 characters (tokenised) excluding line number Maximum 251 characters (tokenised) excluding line number
Integer variables32 bits, signed (−2147483648 to +2147483647)
64 bits, signed (−9223372036854775808 to +9223372036854775807)
32 bits, signed (−2147483648 to +2147483647)
64 bits, signed (−9223372036854775808 to +9223372036854775807)
Floating-point (real) variables Default 64-bit mantissa plus 16-bit exponent (±3.4E−4932 to ±1.1E4932); precision approximately 19 significant figures.
Optionally 53-bit mantissa plus 11-bit exponent (±2.3E−308 to ±1.7E308); precision approximately 15 significant figures
53-bit mantissa plus 11-bit exponent (±2.3E−308 to ±1.7E308); precision approximately 15 significant figures
String variablesLength limited only by available memory Length limited only by available memory
Array variablesMaximum number of dimensions 255, maximum size of each dimension limited only by available memory Maximum number of dimensions 255, maximum size of each dimension limited only by available memory
Number of variablesLimited only by available memory Limited only by available memory
Length of variable namesLimited only by available memory and maximum line length Limited only by available memory and maximum line length
Levels of nestingLimited only by available memory Limited only by available memory

Example programs

A number of example programs are supplied with BBC BASIC for SDL 2.0. They can be found in the examples folder (this is the default file folder following installation).

The example programs are located in sub-folders under the following categories:


2048.bbc Slide the numbered tiles to combine them in pairs until you reach a total of 2048.
Rubik.bbc Displays a 3D-animated Rubik's cube and solves it from any starting point.
animal.bbc A 'guess the animal' game which learns from experience (well, almost!).
buggy.bbc A 'driving' game in which you need to avoid the verges and potholes.
dibley.bbc A puzzle in which you have to work out how to move obstacles to reach the exit.
dropperz.bbc Dodge, catch or shoot at various objects dropped by the alien invader.
gorillas.bbc Two gorillas hurl bananas at each other over the rooftops (choose human or computer control).
hangman.bbc The traditional word-guessing game, with animated graphics.
hanoi.bbc Solves the 'Towers of Hanoi' problem; not really a game as the computer does all the work!
jigsaw.bbc Solve a jigsaw puzzle, you can choose how many pieces and even use your own picture.
lemmings.bbc  Guide the lemmings to safety, based on a Liberty BASIC demo program.
snake.bbc A colourful version of the well-known game in which a snake grows longer as it eats.
sudoku.bbc Plays and solves the popular number puzzle.
triples.bbc Move the wooden objects to create a row of three or more that are identical.


Ceefax.bbc Simulates the television text service, using the BBC's RSS feeds as the source of information.
SkyBaby.bbc An astronomy program which helps locate objects and shows where they appear in the sky.
banner.bbc Displays horizontally-scrolling news headlines; uses the xmllib library.
bezierfit.bbc Demonstrates fitting a polyBézier curve to multiple points; uses the aagfxlib library.
client.bbc A chat client, used in conjunction with server.bbc to demonstrate the socklib library.
calendar.bbc A perpetual calendar, to demonstrate the datelib library.
dlgdemo.bbc A demonstration of the creation of a dialogue box.
ellipsefit.bbc Demonstrates fitting an axis-aligned ellipse to four points; uses the aagfxlib library.
kerning.bbc Adjusts the inter-character spacing in order to improve the appearance of proportional-spaced text.
lanchat.bbc A serverless chat program using UDP connections provided by the socklib library.
mode7dem.bbc A program to test and demonstrate MODE 7.
multidem.bbc Creates multiple output windows using the multiwin library.
multitouch.bbc Uses the eventlib library to monitor multiple touch points (requires a touchscreen).
optics.bbc Uses pushbuttons to control a graphical demonstration.
poem.bbc 'Now Press Return', an interactive poem by Roger McGough (© 1981).
polyfit.bbc Demonstrates the use of array arithmetic to solve a mathematical problem.
prompter.bbc Smoothly scrolls text up the screen; uses the nowait library.
scroll.bbc A demonstration of scrolling over a large canvas, using @ox% and @oy%.
server.bbc A chat server, used in conjunction with CLIENT.bbc to demonstrate the socklib library.
sheet.bbc A simple spreadsheet program. See the file sheet.txt for details.
solve.bbc Solves simultaneous equations using the ARRAYLIB library.
sortdemo.bbc An audible and graphical demonstration of different sorting algorithms, based on a QBASIC program.
sorttest.bbc Tests and demonstrates the sortlib library.
telstar.bbc A client for online information services using the old Prestel/Videotex communication protocols.
textedit.bbc A text editor demonstrating the use of the menulib and editbox libraries.
unicode.bbc Demonstrates BBC BASIC for SDL 2.0' multilingual text capability.


aagfxdem.bbc Demonstrates the aagfxlib anti-aliased graphics library.
aliens.bbc A demonstration of BBC BASIC for SDL 2.0sprites.
bounce.bbc Coloured balls bounce across the screen; the program illustrates the use of data structures.
chain.bbc A graphics demonstration using icons with transparent backgrounds.
clock.bbc A very realistic analogue clock display.
disco.bbc Demonstrates the RECTANGLE SWAP statement.
doodle.bbc A simple 'etch-a-sketch' drawing program.
ellipse.bbc Multi-coloured patterns created from rotated ellipses.
fern.bbc A lifelike fractal image produced by a simple formula.
flier.bbc A spacecraft animation.
flood.bbc Demonstrates the PLOT 143 (flood fill to non-background) statement.
jclock.bbc An unusual clock that follows mouse movement. Loosely based on a Javascript program.
lighting.bbc Demonstrates the use of the OpenGL lighting engine.
mandel.bbc Plots the famous fractal very quickly, using shader code.
opengl.bbc A translation to BBC BASIC of an OpenGL 3D graphics demonstration program.
penrose.bbc A well known optical (and auditory) illusion!
persian.bbc A 'Persian carpet' graphics demonstration.
piechart.bbc Demonstrates drawing a pie-chart.
pointer.bbc A demo version of a LOGO like 'turtle graphics' language.
polydots.bbc An animated graphics demonstration showing dots racing around polygons.
polygon.bbc A graphics demonstration program.
pyramid.bbc A demonstration of 3D graphics using the 3D graphics library.
saucer.bbc A simple but effective 3D drawing.
scarab.bbc A scarab beetle-like pattern created from the behaviour of sines and cosines.
sine.bbc Illustrates the 'text at graphics cursor' (VDU 5) mode.
sliderule.bbc A demonstration of large sprites created using FN_createspritefrombmp.
spectrum.bbc  Proves you can display more than 16 colours at once!
snowscene.bbc A winter scene featuring a realistic fractal tree which is different every time.
spotlight.bbc A demonstration of the different types of light provided by the 3D graphics library.
squares.bbc An attractive pattern resulting from the exclusive-or function of the horizontal and vertical coordinates.
surks.bbc A demonstration of drawing 'thick' circles using the VDU 23,23 command.
swirl.bbc A demonstration of drawing 'thick' arcs using the VDU 23,23 command.
teapot.bbc A realistic 'tumbling teapot' animation, using the 3D graphics library.
wheel.bbc A rotating colour wheel, showing the use of *REFRESH to control animation.
world.bbc A 'rotating globe' animation, demonstrating mapping a texture onto a 'curved' surface.


samples A sub-directory containing programs illustrating the capabilities of the Box2D physics engine.
bbclock.bbc  Simulates a 'ballbearing clock'.
cradle.bbc Simulates Newton's Cradle, illustrating conservation of energy and momentum.
crates.bbc  Simulates how falling crates behave when they hit the ground or other crates.
dangle.bbc Simulates the behaviour of a dangling chain; you can grab it!
dunebuggy.bbc Simulates a vehicle with sprung suspension.
lotto.bbc Simulates a lottery selection machine.
pinball.bbc Simulates a pinball machine, seemingly in 3 dimensions!
pintograph.bbc Simulates a drawing machine made with Meccano™ parts.
trebuchet.bbc Simulates the rock-throwing war machine.


brandenburg.bbc  J.S. Bach's Brandenburg Concerto No. 3 as apparently played by a 3D animated street organ.
entertainer.bbc  Plays the popular Scott Joplin piece while displaying an animated piano keyboard.
figleaf.bbc  Another of Scott Joplin's piano rags.
piano.bbc A polyphonic 'piano' using the PC's keyboard.
polly.bbc A demonstration of SOUND and ENVELOPE
skaters.bbc A demonstration of four-voice music, enabled using *TEMPO.
soldiers.bbc Plays a well known tune accompanied by a synchronised 3D animation of the subject matter!
tocfugue.bbc Bach's Toccata and Fugue in D minor, demonstrating stereo sound.
tofair.bbc Another demonstration of four-voice music.
widor.bbc The Toccata from Widor's Organ Symphony number 5.



BBC BASIC for SDL 2.0 is thought to be free from serious bugs, and it is highly unlikely that it could do any harm to other software or systems. However there is NO warranty that it will not and its use is at your own risk.

BBC BASIC for SDL 2.0 is the Copyright © 2015-2021 of R. T. Russell

The name BBC BASIC is used with the permission of the British Broadcasting Corporation.



Best viewed with Any Browser Valid HTML 3.2!
© Richard Russell 2021