www.riscos.com Technical Support:
BBC BASIC Reference Manual



BBC BASIC consists of special keywords with which you create sequences of instructions, called programs, to be carried out by the computer. You can use programs to perform complicated tasks involving the computer and the devices connected to it, such as:

  • performing calculations
  • creating graphics on the screen
  • manipulating data.

Several examples of programs written in BBC BASIC are provided with the RISC OS Applications suite.

The BASIC language operates within an environment provided by the computer's operating system. The operating system is responsible for controlling the devices available to the computer, such as:

  • the keyboard
  • the screen
  • the filing system.

For example, it is the operating system which reads each key you press and displays the appropriate character on the screen. You can enter operating system commands directly from within BASIC, by prefixing them with an asterisk (*). These commands are described in the The RISC OS user guide.

What is BASIC VI?

BASIC VI is the latest version of BBC BASIC, supplied alongside BASIC V with the RISC OS 3 operating system. Its main advantage over BASIC V is that it can handle real numbers with greater accuracy. It does this by using more memory space to store real numbers (8 bytes instead of 5 bytes).

Why use BASIC VI?

Normally, the way in which the computer handles real numbers will not matter to your programs. However, changes to BASIC VI mean that:

  • BBC BASIC is now compatible with all BASIC compilers.
  • Exchanging data between BBC BASIC and other languages, like C, is now easier.
  • BBC BASIC now performs floating point calculations in line with IEEE standard 754.

If you do need to know more about real numbers, Appendix A: Numeric Representation explains in detail how they are stored and manipulated.

You will find a full list of the differences between BASIC V and BASIC VI in Appendix I: BBC BASIC's history.

The BASIC interpreter

When you run a BASIC program, the operating system passes it to the BASIC interpreter. This translates your instructions into a form that the computer can understand (called assembly language).

Different versions of BBC BASIC use different versions of the interpreter. BASIC V and VI both use version 1.05 of the BASIC interpreter. However, you might not have the latest version of BBC BASIC. If you don't have it, this manual also explains, where necessary, how to achieve the same results using version 1.04 of the BASIC interpreter.

Window managed programs

If you wish to write programs that work in the desktop windowing environment you must read The Window Manager chapter in the Programmer's Reference Manual . The Window Manager provides:

  • a simple to use graphical interface
  • the facilities to allow programs to run in a multitasking environment, so that they can interact with each other, and with other software.

The Window Manager is usually referred to as the Wimp (Windows, Icons, Menus and Pointer) and it simplifies the task of producing programs that conform to the notion of a 'desktop', where the windows represent documents on a desk. An example of a BASIC program written under the window environment is !Patience.

Commands to avoid

If you do decide to write a window managed program you must be careful to avoid the commands in BASIC which will either interfere with the running of other programs under the Wimp, or simply not work at all. These include:

Avoid Described in Reason
GET, INKEY, INPUT Inputting these commands work under the Wimp, but can cause problems
*FX commands *FX Commands Some *FX commands should be avoided under the Wimp; for example, using the Tab and cursor keys to get ASCII codes
COLOUR, MODE Screen Modes

these commands will interfere with other programs - use the facilities provided by the WIMP instead. For example:
SYS "ColourTrans_SetGCOL"
SYS "Wimp_SetColour",0

Flood-filling Graphic Patterns flood-filling is not usable under the Wimp
Viewports Viewports the Wimp uses its own viewports

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015