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), Raspberry Pi OS, 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), although the assembler in the iOS edition is effectively unusable because of restrictions imposed by Apple. The in-browser edition is an exception and does not have an assembler. You can access the SDL 2.0 Application Program Interface both from BASIC and from assembler code.

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. You can also create a web bundle for running in a browser.

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.


The desktop editions of BBC BASIC for SDL 2.0 can be run in a number of ways: Each of these methods starts BBC BASIC for SDL 2.0 and runs the program bbcsdl.bbc in the same directory, if present. By default this program displays the Choose IDE window, or if you have selected 'Don't ask me again' it runs the IDE that you have previously selected. If no file bbcsdl.bbc is present, BBC BASIC starts with the traditional immediate-mode interface.

Alternatively you can specify a BASIC program that you want to be run, by entering the command bbcsdl myprog.bbc which will run the program myprog.bbc.

The desktop editions of BBC BASIC for SDL 2.0 accept the following command-line switches:

bbcsdl myprog.bbc -fullscreen  Start in full-screen mode rather than windowed.
bbcsdl myprog.bbc -fixedsizeStart with a non-resizable window.
bbcsdl myprog.bbc -borderlessStart with a borderless window.
bbcsdl myprog.bbc -hiddenStart with a hidden window.
The in-browser edition of BBC BASIC for SDL 2.0 accepts the following URL parameters:
?run=<path/program>   Run the specified supplied example program.
?dir=<path>Use the specified directory for subsequent files.
?load=<url>Load the specified file (sub-module or resource file).
?chain=<url>Load and run the specified program (must be .bbc).
?embed=<base64>Run the .bbc program given inline (base64url encoded).
?app=<url>Load and run the specified application bundle (.bbb file).
As usual, if multiple parameters are supplied the first begins with ? and the remainder with &.

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 later preferred), 32-bits or 64-bits.
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), Chrome or Firefox on Android, Safari on iOS.


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 32 Mbytes, maximum 256 Mbytes (4 Gbytes for 64-bit editions) Default approximately 32 Mbytes, maximum 256 Mbytes (4 Gbytes for 64-bit editions, 48 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 variables8-bits, unsigned (0 to 255)
32 bits, signed (−2147483648 to +2147483647)
64 bits, signed (−9223372036854775808 to +9223372036854775807)
8-bits, unsigned (0 to 255)
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.
bugs.bbc Try to collide the ladybirds, based on the 2006 Flash game 'Ladybug Sumo'.
cowboy.bbc A simple 2D shoot-'em-up game, to illustrate the use of the gfxlib library.
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.
analyser.bbc A real-time audio spectrum analyser which uses the dot-product to calculate a Fourier Transform.
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.
calendar.bbc A perpetual calendar, to demonstrate the datelib library.
calculator.bbc A calculator with two modes, scientific and integer, making use of the EVAL function.
client.bbc A chat client, used in conjunction with server.bbc to demonstrate the socklib library.
conway.bbc A version of Conway's Game of Life cellular automaton, with calculations performed by the GPU.
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.
pdfdemo.bbc Illustrates the use of the pdflib library.
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.
recorder.bbc (Desktop editions only) An audio recorder which saves the clip to a WAV file.
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.
server_multi.bbc A server which can accept up to eight concurrent connections.
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.
timerdem.bbc A demonstration of the timerlib library.
unicode.bbc Demonstrates BBC BASIC for SDL 2.0' multilingual text capability.
video.bbc Demonstrates playing a video, albeit that compressed formats such as mp4 aren't supported.
welcome.bbc The Intro program from the BBC Micro Welcome Disc.


aagfxdem.bbc Demonstrates the aagfxlib anti-aliased graphics library.
aliens.bbc A demonstration of BBC BASIC for SDL 2.0 sprites.
anigif.bbc A demonstration of displaying an animated GIF image using the imglib library.
bounce.bbc Coloured balls bounce across the screen; the program illustrates the use of data structures.
candle.bbc A realistic simulation using the gfxlib library.
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 'virtual sliderule' demonstrating large 'sprites' drawn using *DISPLAY.
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.
smithchart.bbc A Smith Chart graticule drawn using anti-aliased graphics.
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.


blacksmith.bbc J.S. Bach's The Harmonious Blacksmith, accompanied by a 3D animation of a forge.
brandenburg.bbc  J.S. Bach's Brandenburg Concerto No. 3 as apparently played by a 3D animated street organ.
carousel.bbc Thunder & Blazes by Julius Fučic, accompanied by a 3D carousel animation.
entertainer.bbc  Plays the popular Scott Joplin piece while displaying an animated piano keyboard.
figleaf.bbc  Another of Scott Joplin's piano rags.
metronome.bbc A graphical metronome which actually works.
piano.bbc A polyphonic 'piano' using the PC's keyboard.
polly.bbc A demonstration of SOUND and ENVELOPE
skaters.bbc Waldteufel's Skaters' Waltz (Les Patineurs) accompanied by a 3D animation.
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 A demonstration of four-voice music, enabled using *TEMPO.
widor.bbc The Toccata from Widor's Organ Symphony number 5.


BBCEdit.bbcAndy Parkes' Interactive Development Environment.
SDLIDE.bbcRichard Russell's Interactive Development Environment.
addconst.bbcUtility to add SDL constant declarations (access via the SDLIDE Utilities menu).
compiler.bbcUtility to create an application bundle (access via the SDLIDE Utilities menu).
crossref.bbcCross Reference utility (access via the SDLIDE Utilities menu).
getri.bbcUtility to show information about your display's rendering capabilities.
hello.bbcUtility to demonstrate the use of the inline assembler (when available).
listvars.bbcList Variables utility (access via the SDLIDE Debug command).
macrorec.bbcUtility to program the function keys (access via the SDLIDE Utilities menu).
memmon.bbc  Run-time memory monitor utility (access via the SDLIDE Utilities menu).
mmap.bbcUtility to display a memory map (Linux and Android only).
profiler.bbcRun-time profiler utility (access via the SDLIDE Run menu).
saa505x.bbcUtility to display the language character sets available in MODE 7.
searchin.bbcSearch BASIC programs utility (access via the SDLIDE Utilities menu).
settab.bbcPrograms the Tab key to move to a specified column in the SDLIDE editor.
sysvars.bbcUtility to display the virtual memory addresses of the 'system variables'.
timing.bbcTimes various operations to provide a comparative measure of interpreter speed.
touchide.bbcThe simplified IDE used by the Android, iOS and in-browser editions.


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-2024 of R. T. Russell

The name BBC BASIC is used with the permission of the British Broadcasting Corporation and is not transferrable to any derived or forked work.



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