RISCOS.com

www.riscos.com Technical Support:
RISC OS 3 User Guide

 

RISC OS 3.7 User Guide


Appendix D: BBC BASIC


BBC BASIC is still one of the most popular and widely-used programming languages. It consists of special keywords from which the programmer can create sequences of instructions, or programs, to be carried out by the computer. Such programs might perform calculations, create graphics on the screen, manipulate data, or carry out virtually any action involving the computer and the devices connected to it.

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, and the filing system. For example, it is the operating system which reads each key you press and displays the appropriate character on the screen. Operating system commands can be entered directly from within BASIC by prefixing them with an asterisk (*).

If you want to find out more about the BBC BASIC programming language, you need the BBC BASIC Reference Manual available from your Acorn supplier.

On-line help is available within BASIC; just type HELP (in uppercase) for more information.

BBC BASIC V and VI

There are two variants of BBC BASIC supplied with RISC OS 3, BASIC V and BASIC VI.

BASIC V is in the ROM and is almost identical to the BASIC V supplied with earlier versions of RISC OS. A small number of faults have been corrected.

BASIC VI is essentially the same as BASIC V, but it uses 8 bytes (or 64 bits) to store floating point numbers. BASIC V only uses 5 bytes, so it is slightly less accurate. The 8 byte representation used follows the IEEE standard. Unlike BASIC V, BASIC VI makes use of a hardware floating point unit if it is fitted.

Entering BASIC

Basic V

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 BASIC, press Return, and the BASIC V version and memory will be displayed on the screen.

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

Basic VI

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:

  System:Modules.BASIC64

Press Return, and the BASIC VI version and memory option will be displayed on the screen. (Note: You can't just type BASIC64, as the BASIC64 module is not in the library directory).

BASIC 64 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 (which must be in uppercase) or type *Quit.

Features in BASIC VI

The CRUNCH command strips various spaces from a program. Its argument is a 5-bit binary word. Each bit in the word has a different meaning (for instance bit 0 controls the stripping of spaces before statements; bit 2 controls the stripping out of REM statements).

The TEXTLOAD command can load a file that is either a BASIC program, or a BASIC program that was saved as a text file. In the latter case, TEXTLOAD automatically renumbers the program. TEXTSAVE stores a BASIC program as a text file, and strips out the line numbers.

Writing and editing BASIC files

Edit will automatically convert BASIC files to and from BASIC tokenised format. Now all editing of BASIC files can be done using Edit.

Command line syntax for BASIC

The following pages describe in full the command line interface for BASIC V and BASIC VI.

*BASIC   The command to enter the BASIC V interpreter.

Syntax   *BASIC [options] Purpose   To enter BASIC V.

The options control how the interpreter will behave when it starts, and when any program that it executes terminates. If no option is given, BASIC simply starts with a message of the form;

  ARM BBC BASIC V version 1.05 (C) Acorn 1989
  Starting with 643324 bytes free

The number of bytes free in the above message will depend on the amount of memory in your Next slot. The first line is also used for the default REPORT message, before any errors occur.

One of three options may follow the *BASIC command to cause a program to be loaded, and, optionally, executed automatically. Alternatively, you can use a program that is already loaded into memory by passing its address to the interpreter. Each of these possibilities is described in turn below.

In all cases where a program is specified, this may be a tokenised BASIC program, as created by a SAVE command, or a textual program, which will be tokenised (and possibly renumbered) automatically.

  *BASIC -help

This command causes BASIC to print some help information describing the options documented here. Then BASIC starts as usual.

  *BASIC [-chain] <filename>

If you give a filename after the *BASIC command, optionally preceded by the keyword -chain, then the named file is loaded and executed. When the program stops, BASIC enters immediate mode, as usual.

  *BASIC -quit filename

This behaves in a similar way to the previous option. However, when the program terminates, BASIC quits automatically, returning to the environment from which the interpreter was originally called. If you have a variable BASIC$Crunch defined it also performs a CRUNCH %1111 on the program. This is the default action used by BASIC programs that are executed as * commands. In addition, the function QUIT returns TRUE if BASIC is called in this fashion.

  *BASIC -load <filename>

This option causes the file to be loaded automatically, but not executed. BASIC remains in immediate mode, from where the program can be edited or executed as required.

  *BASIC @start,end

This acts in a similar way to the -load form of the command. However, the program that is 'loaded' automatically is not in a file, but already in memory. Following the @ are two addresses. These give, in hexadecimal, the address of the start of the in-core program, and the address of the byte after the last one. The program is copied to PAGE and tokenised if necessary.

Note that the in-core address description is fixed format. It should be in the form;

  @xxxxxxxx,xxxxxxxx

where x means a hexadecimal digit. Leading zeros must be supplied. The command line terminator character must come immediately after the last digit. No spaces are allowed.

  *BASIC -chain @start,end

This behaves like the previous option, but the program is executed as well. When the program terminates, BASIC enters immediate mode.

  *BASIC -quit @start,end

This option behaves as the previous one, but when the BASIC program terminates, BASIC automatically quits. The QUIT flag will return TRUE during the execution of the program.

Examples

  *BASIC
  *BASIC -quit shellProg
  *BASIC @000ADF0C,000AE345
  *BASIC -chain fred

*BASIC64

*BASIC64 is the command to enter the BASIC VI interpreter.

Syntax   *BASIC64 [options]

This assumes that the BASIC64 module has been 'seen'. If not, you need to type

  *System:Modules.BASIC64

This has exactly the same purpose as the *BASIC command, and takes the same options, the only difference being that it enters the BASIC VI interpreter instead of the BASIC V interpreter. Additionally CRUNCH is used automatically by BASIC64.

If no option is given, BASIC VI simply starts with a message of the form;

  ARM BBC BASIC VI version 1.05 (C) Acorn 1989
  Starting with 581628 bytes free.

The number of bytes free in the above message will depend on the amount of free space in your Next slot.

Examples

  *BASIC64
  *BASIC64 -quit shellProg
  *BASIC64 @000ADF0C,000AE345
  *BASIC64 -chain fred

Features available in RISC OS 3 Version 3.50 or later

The version of BASIC in your computer has been extended for use with the new systems available.

Colour

Mode

Set the screen mode.

See Changing the desktop size without changing the resolution for more information about this string.

As a function MODE gives the current screen mode.

MODE has been extended to take a pointer to a mode selector or a mode string. A mode selector is passed to OS_ScreenMode, whereas a mode string is passed to *WimpMode. The result is that if a program changes screen mode using a mode string, e.g. MODE "X800 Y600 C256 EX1 EY1", then when the program finishes that will be your desktop mode.

It should also be noted that the C/G option in the mode string is implemented by *WimpMode. Hence, MODE MODE will select a default palette mode for the given current mode depth. This means that if a grey mode is selected by MODE "X800 Y600 G256 EX1 EX1" then MODE MODE will revert back to the coloured palette.

Point

POINT (X,Y) supports 16bpp and 32bpp colours.


RISC OS 3.7 User Guide - 20 JAN 1997

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