RISCOS.com

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

 


Command mode


This chapter describes how to enter and leave BASIC, and how command mode works while within BASIC.

Entering BASIC

BASIC V

BASIC V is supplied with both RISC OS 2.00 and RISC OS 3.

From RISC OS 2.00

Load Edit. From the Edit icon bar menu, choose Create/New Task window, and then type the following:

BASIC

Press Return, and the BASIC V version and memory option will be displayed on the screen.

From RISC OS 3

To start BASIC V, display the Task manager menu (click Menu over the Acorn icon at the bottom righthand corner of the desktop). Choose the Task window option and then type the following:

BASIC

Press Return, and the BASIC V version and memory option will be displayed on the screen.

BASIC can also be started in both RISC OS 2.00 and RISC OS 3 from the New Task option on the Task Manager or from the command line (press F12).

BASIC VI

BASIC VI is supplied with RISC OS 3 only.

BBC BASIC VI is different to BBC BASIC V in that it is stored on disc, not in the computer's ROM. BASIC VI is also known as BASIC64.

BASIC VI is used by some applications (for example SciCalc) so it may get loaded into memory without you having to take any special action.

To start BASIC VI, display the Task manager menu (click Menu over the Acorn icon at the bottom righthand corner of the desktop). Choose the Task window option and then type the following:

BASIC64

Press Return, and the BASIC VI version and memory option will be displayed on the screen. If BASIC VI is not loaded you will get the error message:

File 'BASIC64' not found

If you get this error message then you should type:

SYSTEM:MODULES.BASIC64

Press Return, and the BASIC VI version and memory option will be displayed on the screen.

If you now get the error message

File 'system:modules.basic64' not found

then either you have not seen a !System directory, in which case you should open a directory display on the directory containing your !System, or your !System does not contain a copy of BASIC64. If you don't have BASIC64, you should update it from the !System on the applications discs.

BASIC can also be started from the New task option on the Task manager menu or from the command line (press F12).

BASIC files saved from both BASIC V and BASIC VI are the same and can be run using either BASIC.

Leaving BASIC

To leave BASIC, type QUIT, then press Return twice to get back to the desktop.

Command mode

When you enter BASIC it is in command or interactive mode (sometimes this is termed immediate mode). This means that you can type commands and the computer responds straight away. For example, if you type

PRINT "Hello"

the computer displays the following on the screen:

Hello

PRINT is an example of a keyword which the computer recognises. It instructs the computer to display on the screen whatever follows the PRINT statement enclosed in quotation marks. Keywords are always written in upper case letters (capitals).

If you make a mistake, the computer may not be able to make sense of what you have typed. For example, if you type:

PRINT "Hello

the computer responds with the message:

Missing "

This is an error message. It indicates that the computer cannot obey your command because it does not follow the rules of BASIC (in this case because the computer could not find a second quotation mark).

If PRINT is followed by any series of characters enclosed in quotation marks, then these characters are displayed on the screen exactly as you typed them. Thus:

PRINT "12 - 3"

produces the output:

12 - 3

PRINT, however, can also be used to give the result of a calculation. For example, typing

PRINT 12 - 3

produces the output:

9

In this case, because the sum was not enclosed in quotation marks, the computer performed the calculation and displayed the result.

Similarly, multiplication and division can be performed using the symbols * and /. For example:

PRINT 12 * 13
PRINT 111 / 11

Some commands, although they have an effect on the computer, do not give evidence that anything has changed. If, for example, you type

LET FRED = 12

nothing obvious happens. Nevertheless, the computer now knows about the existence of a variable called FRED which has the value 12. A variable is a name which can have different values assigned to it. It is described in more detail later in this manual.

Now if you type

PRINT FRED / 3

the computer responds by displaying the number 4.

The program below illustrates how you can give commands to produce some graphics on the screen:

MODE 12
CIRCLE FILL 600,500,100

The MODE command sets up the computer to produce high resolution graphics (640 by 256 dots in 16 colours). It also clears the screen.

The CIRCLE FILL command tells the computer to draw a circle at a position 600 dots across from the left of the screen and 500 dots up from the bottom. This is near the centre of the screen because the screen is 1280 units across and 1024 units high. The third number tells the computer how big the circle should be, in this case giving a radius of 100 dots.

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