Section Ten - BBC BASIC

PipeDream can be used to carry out most of the operations you are likely to want to perform on text and numbers, such as entering and editing, searching, sorting and calculating. However, some problems would require you to carry out, a sequence of different operations and this might be cumbersome and time-consuming using PipeDream. For this sort of problem you can turn to the BBC BASIC programming language which is provided in your Cambridge Z88.

Programming languages are designed to allow you to instruct the computer to carry out a sequence of operations on text or numbers. BASIC is one such general-purpose programming language, and is the most widely used language on microcomputers. BASIC has a significant advantage over many other languages in that it is interactive: you can make changes to a sequence of instructions, and see the result immediately without having to perform any intervening operations. This means that programs can be developed relatively quickly.

BBC BASIC programs can be converted into full Cambridge Z88 applications, stored on a ROM card. A package called BAGZ is available, which provides all the necessary programs to create an application and write it onto an EPROM card, without needing to use an external computer.

This section provides a reference list of all the Cambridge Z88 BBC BASIC language keywords. It is not intended as a tutorial on the BASIC language; many excellent books on this subject already exist.

The keywords are divided into four types:

  • Commands are instructions that can be typed from the keyboard to assist in creating a program, and testing it out. Commands are typed from the keyboard in immediate mode after the BASIC > sign prompt, and they may not be used within programs.

  • Statements are the special keywords that are used within programs, after a line number, to instruct the computer to do something. Most statements can also be typed directly after the BASIC prompt, and are then executed immediately so that you can try out their effect.

  • The BASIC statements are normally the first keyword after the line number in a program line.

  • Functions can be included in expressions, and will return the result of performing an operation on the arguments enclosed in brackets after their name. They are similar to the functions in PipeDream.

A function can be followed by one or more arguments, and returns a number or a string. Functions which take only one argument require brackets around the argument only if it is a complex expression. If the argument is a simple number, variable, or another function, no brackets are required.

Finally, the operators can be used to link the components of expressions.


The following keywords, associated with graphics, sound, and analogue operations in other versions of BBC BASIC, give the error

Sorry, not implemented

on the Cambridge Z88:

Graphics: CLG, COLOUR, DRAW, GCOL, MODE, MOVE, PLOT, POINT
Sound: ENVELOPE, SOUND
Analogue: ADVAL

Entering BBC BASIC

You enter BBC BASIC by selecting BASIC from the Index APPLICATIONS LIST, or by typing B from any application. The initial BASIC screen will then be displayed:

In an unexpanded machine, BASIC will have a workspace of 8K. If the machine is expanded then it will have a 40K workspace. See Expanded/Unexpanded.


Entering keywords

Many keywords may be abbreviated when entered into a program, and will be expanded by the BASIC interpreter. In such cases the shortest abbreviation is shown in brackets after the full form; eg AUTO (AU.).

All keywords must be entered in capitals, as shown in the following alphabetical list. Inverted Caps mode can be selected by typing  

CAPSLOCK
. To give capital letters when the Cambridge Z88 keys are typed alone, and lowercase letters when typed with the 
SHIFT
key. Press  
CAPSLOCK
to restore ordinary Caps mode.

Editing BASIC programs

The following program provides BBC BASIC on the Cambridge Z88 with a line editor. The line editor works as follows:

  1. To edit a line you need to type: PROCE(Iine number

    ENTER

    The editor will list out the line and put the cursor at the end.

  2. You can now use the cursor keys to move within the line and make changes, and most of the edit commands available in PipeDream such as Delete Word etc.

  3. When you have made all the changes you want, press 

    ENTER
    to store the line back in the program. If you want to abandon the changes you have made then press  
    ESC
    and the line will be left unchanged.

Before you can use the editor you must type in the following program. You can then start writing your own program. When you save your program the editor will be saved with it.

60000 END
60010 DEF PROCE(B)
60020 REM Cambridge Computer Ltd.
60030 IF B=0 THEN ENDPROC
60040 A=OPENOUT":RAM.0/EE.CLI"
60050 B$=":RAM.0/E.CLI"
60060 PRINT#A,".>"+B$
60070 PRINT#A,".J","LIST"+STR$(B),"PROCF"
60080 CLOSE#A
60090 *CLI .*:RAM.O/EE.CLI
60100 ENDPROC
60110 DEF PROCF
60120 A=INKEY(0)
60130 A=OPENIN B$
60140 INPUT#A,A$,A$
60150 CLOSE#A
60160 A=OPENOUT B$
60170 PRINT#A,".J",A$
60180 PTR#A=PTR#A-1
60190 BPUT#A,0
60200 CLOSE#A
60210 VDU 8
60220 OSCLI"*CLI .<"+B$
60230 ENDPROC

If you have several existing programs which you would like to append the editor to you must type the editor into PipeDream. On the first line you must include the CLI command .J . Now save the file in plain text format as EDBAS. When you want to use the editor start a BASIC application and load the program you want to edit. To append the editor onto the end of your program type:

*CLI .*EDBAS 

ENTER
where EDBAS should be in the directory selected by this application.

Note that if your program uses line numbers above 60000 you should renumber it first before appending the editor.

The editor generates two working files in :RAM.0 called /EE.CLI and /E.CLI. The files can be erased after use. If you have a RAM card in slot 1 or slot 2 you could alter the program to save its working files in :RAM.1 or :RAM.2 by changing lines: 60040, 60050, and 60090.

Printing from BASIC

The following program shows how to print from a BASIC program:

100 LET PRT_ON$=CHR$(5)+"["
110 LET PRT_OFF$=CHR$(5)+"]"
120 LET LF$=CHR$(10)
130 :
140 LET PRT=OPENOUT":PRT*
150 IF PRT=0 THEN PRINT" CAN'T OPEN PRINTER*":STOP
160 :
170 PRINT#PRT,PRT_ON$
180 FOR I=1 TO 4
190    PRINT#PRT,"Text "+STR$(I*PI)+" and numbers!"+LF$ 200 NEXT I
210 PRINT#PRT,PRT_OFF$
220 :
230 CLOSE#PRT

When run it prints the following:

Text 3.14159265 and numbers!
Text 6.28318531 and numbers! 
Text 9.42477796 and numbers!
Text 12.5663706 and numbers!

web analytics