Index Chapter 1

CP/M Plus

and

Mallard BASIC

for the Spectrum +3

USER GUIDE


© Copyright 1988 Locomotive Software Limited
Sections of the text: © 1985, 1987 AMSTRAD plc

All rights reserved.

Neither the whole, nor any part of the information contained in this manual may be adapted or reproduced in any material form except with the prior written approval of Locomotive Software Limited.

While every effort has been made to verify that this software works as described, it is not possible to test any program of this complexity under all possible circumstances. Therefore the software supplied in this package is provided 'as is' without warranty of any kind either express or implied.

The particulars supplied in this manual are given by Locomotive Software in good faith. However, the software described is subject to continuous development and improvement , and it is acknowledged that there may be errors or omissions in this manual. In particular, the messages shown in this manual may differ in detail from those actually shown on the screen.

Locomotive Software reserves the right to revise this manual without notice.

Written and edited by Jean Gilmour, Locomotive Software
(Includes material written for AMSTRAD plc and material written by Ed Phipps Documentation Services for Locomotive Software)
Produced and typeset electronically by Locomotive Software Ltd
Printed by Ashford Colour Press, Gosport, Hants

Published by Locomotive Software Ltd
Allen Court
Dorking
Surrey RH4 1YL

First Published 1988
ISBN 1 85195 011 7

LOCOMOTIVE and LOCO are registered trademarks of Locomotive Software Ltd
Mallard BASIC is a trademark of Locomotive Software Ltd
AMSTRAD is a registered trademark of AMSTRAD plc
Spectrum +3, PCW8256, PCW8512, PCW9512, CPC6128 are trademarks of AMSTRAD plc
CP/M, CP/M Plus are trademarks of Digital Research Inc
WordStar is a trademark of MicroPro International Corp
VT52 is a trademark of Digital Equipment Corp
Z19, Z29 are trademarks of Zenith Data Systems Inc


Introduction

CP/M for the Spectrum +3 comprises:

CP/M is an operating system which means that its job is to run programs and help you organise your data. CP/M makes each computer on which it is used behave in the same way. As CP/M is used on many different computers the world over, you will have many thousands of programs from which to choose - programs that might have originally been written with another computer in mind but which will run equally well on your Spectrum +3. These programs might be accountants' spreadsheets or word processors - even computer games (though perhaps without some of the spectacular effects of programs written specifically for the Spectrum).

What is particularly important is that CP/M Plus for the Spectrum +3 is fully compatible with the CP/M for other Amstrad computers - the CPC6128 personal computer and all the PCW machines. So CP/M programs supplied for these computers are automatically set up correctly for running on your Spectrum +3.

One of the main advantages of using a well-established operating system such as CP/M is that it opens up a wide range of professional programming languages to you. Locomotive Software's Mallard BASIC, supplied on the disc alongside CP/M, is just such a programming language.

Mallard BASIC is a powerful modern BASIC with a number of significant improvements. In particular, Mallard BASIC has the very unusual facility (for BASICs on microcomputers) of indexing data stored in a file and automatically keeping this index in alphabetical order. This takes all the hard work out of preparing and using your own database.

In addition, Mallard BASIC will accept programs written for the industry standard Microsoft BASIC with little or no modification.

About this User Guide

This User Guide is in three parts:

Part I gives you all the information you need for general use of the CP/M Plus operating system; Part II is specifically to help you use the Mallard BASIC programming language supplied on the disc; Part III provides reference information on CP/M for the Spectrum +3.

Part II provides only an introduction to Mallard BASIC. If you wish to use Mallard to write anything more than very simple programs, we would recommend you to buy a copy of 'Mallard BASIC: Introduction and Reference' (available from Locomotive Software, price £9.95).

Essential Preparation

The first thing to do is to make a copy of the supplied Master CP/M disc. You need this copy to give yourself a disc to use every day to load CP/M. (Such a disc is often described as a Start-up disc.) The supplied disc shouldn't be used as your Start-up disc because then you would risk damaging the disc and losing all the valuable software on it. Instead, it should be stored safely away, to use only to make another copy if your 'Working' copy gets damaged.

Copying a disc means copying all the data from one disc to another in such a way that the second disc becomes identical to the first. The program that does this is called DISCKIT. To use DISCKIT, you simply load the program and then follow instructions on the screen. The whole process should take about five minutes. The steps to take are given below: these assume that your Spectrum +3 is switched off at the start.

You also need to give yourself a 'Data' disc to store any other programs and data on. It is best not to use your Start-up disc as anything other than the disc you use to load CP/M and its associated 'utility' programs.

You will need two new blank discs for this - one for your copy of the supplied disc, and one for your Data disc.

Initial steps

  1. Write 'CP/M Start-up disc' on the label on Side 1 of the disc you are going to use as your CP/M Start-up disc.
  2. Write-protect the supplied disc, by ensuring that the Write Protect Holes in the top corners of the disc (away from the disc label) are open.
    This step is most important as it protects the supplied disc against being accidentally overwritten while the disc is being copied.
  3. Check that there is no disc in the drive; then turn the machine on. Your Spectrum then displays its standard Opening Menu.
  4. Hold the supplied master disc by its labelled end with Side 1 uppermost and insert it into the built-in floppy disc drive (Drive A).
  5. Check that the Loader option is highlighted, and then press [Enter]. The Spectrum then displays the message Loader and reads from the disc.

    If all is well, the Spectrum then displays a message like:

    	CP/M Plus Locomotive Software Ltd
    	vx.x, 61K TPA, 1 disc drive
    	
    	RAMDISC vx.x [size=12k] installed
    
    and carries out a few extra commands. Finally it stops, with A> on a fresh line followed by a bright oblong.

    If instead the screen flashes red or you see the message Insert TAPE and press PLAY, the disc you've used either isn't suitable for loading in a Spectrum or is damaged in some way. Check that you inserted the correct disc then try again. If it still fails, take the disc back to your dealer.

Copying the Master disc

  1. Leave the 'Master' CP/M disc in the drive, type DISCKIT (you will see the characters appear on the screen after the A> prompt.) and press the [Enter] key.
  2. Up on the screen will come a series of messages. The first message tells you to remove your disc; press [Enter] (say) when you have done this.
  3. The next message offers you the choice of Copy, Format or Verify (or exit from DISCKIT) and tells you which key to press to select each option. In this case, you want Copy, so press the 1 key.
  4. If your Spectrum has two floppy drives, you will be asked which drive you want to read from - press A for Drive A, the built-in disc drive; you will then be asked which drive you want to write to - press Q for drive B, your second disc drive. If your Spectrum just has one disc drive, this stage is omitted.
  5. The next message that appears asks you to '...put the disc you wish to READ into the drive, then press Y'. In this case, the disc you want to copy is the supplied Master disc, so re-insert this disc with side 1 uppermost and type Y.

    Copying will now start. You will see the system counting through the numbers 0...39 both as it reads the information on the Master disc and as it writes the copy on the new disc. If you have a single-drive system, copying will take place in a number of parts - each part copying a section of information on the disc to READ (the supplied disc) onto the disc to WRITE (the disc you've labelled 'CP/M Start-up disc'). This involves swapping the disc you have in the drive at various points in the process in response to messages displayed on the screen.

  6. When a message appears asking you to insert the disc to WRITE, insert the new blank disc in the drive specified in the message, with Side 1 (the side you labelled) uppermost, and press [Enter].

    DISCKIT will start to write the information it has copied from the Master disc onto the new disc. If the new disc hasn't yet been marked out ready to store information, DISCKIT will display a message telling you it is 'Going to format the disc in drive A: while copying'.

  7. On a single-drive machine, the following message will appear after a short while:
    	Insert disc to READ into drive A:
    	Press any key to continue
    
    You must now re-insert the supplied disc so that the second part of the copy can go ahead (press [Enter] when you have done this). After a while, you will similarly be asked to insert the disc to WRITE again - and so on until the whole of the disc has been copied (four pairs of operations).

    If you accidentally mix up the disc you are reading from (the Read disc) and the disc you are writing to (the Write disc) DISCKIT will spot this and display an appropriate message.

    Any error messages that appear should also be self explanatory, but if you feel in need of extra help, refer to Part I, Chapter 5 where full details of DISCKIT are given.

  8. When copying is complete, you will see the message:
    	Copy completed
    	Remove the disc from the drive
    	Press any key to continue
    
    Release the disc(s) from the drive(s) and press [Enter]. You have now copied Side 1 of the Master disc onto your CP/M Start-up disc.
  9. You are next asked whether you want to copy another disc. The second side of the Master disc counts as another disc, so re-insert the Master CP/M disc - this time with Side 2 uppermost - and press Y.

    Side 2 of the Master disc is copied as before. When a message appears asking you to insert the disc to WRITE, insert your new disc in the drive specified in the message - this time with Side 2 uppermost - and press [Enter].

  10. This time when copying has been completed, remove your new disc from the drive and put it to one side; you hae now made your working CP/M Start-up disc. Then press [Enter] twice to return to DISCKIT's main menu.

Preparing a Data disc

You now need to use DISCKIT to prepare your second blank disc as your Data disc. Important: Do not use a disc that already has information stored on it unless you are sure that you do not want that data. The process described here completely erases any information currently on the disc.

  1. The process of preparing a disc is called Formatting, so this time the option you want to use from this menu is Format - ie. press the Q key.
  2. If your Spectrum has two floppy discs, you will be asked which drive you want to format the disc in - press A for Drive A, the built-in disc drive.
  3. The next message that appears asks you to '...put the disc to FORMAT into the drive, then press Y'. Insert your second new disc and type Y.

    Formatting will now start. You will see the system counting through the numbers 0...39 as it prepares the new disc.

  4. When formatting is complete, you will see the message Format completed. Release the new disc from the drive and press [Enter]. You have noew formatted Side 1 of your Data disc.
  5. You are next asked whether you want to format another disc. The second side of the new disc counts as another disc, so re-insert your Data disc - this time with Side 2 uppermost - and then press Y.

    Side 2 of the disc is then formatted as before.

  6. This time when copying has been completed, remove your new disc from the drive and put it to one side; you have now made yourself a Data disc. Then press [Enter] twice to return to DISCKIT's main menu.
  7. Finally press M to leave DISCKIT.
IMPORTANT: Store your CP/M Master disc safely somewhere where it will be away from any magnets - including the ones in your television and your audio equipment - and where it won't get very hot, very cold, damp or dirty.

Conventions

Throughout this user guide, various conventions are used to represent different types of information. The principal conventions are as follows:

INPUT, PRINT, etc.
The names of commands and programs are shown in capital letters throughout this user guide. It does not matter whether you type these names as capitals or as lower case letters.
text in this style
This style of text is used to indicate something to type or something displayed on the screen, in order to distinguish it from descriptive text. This text should be typed exactly as shown. In particular, you must be careful to use the correct type of brackets. If square brackets [ and ] are shown, you cannot use round brackets ( and ) instead. However, letters shown here as capitals can be typed in either upper or lower case.
descriptions-in-italic
Italic text is used for descriptions of the type of information that is required, rather than the information itself. For example, number could be 1 or 2 or 3 etc. If the description of a single item is more than one word long, the words are joined by hyphens: for example, line-number.

The majority of descriptions are explained in the accompanying text. The remainder are self-explanatory.

[items in slanted brackets]
Slanting brackets round an item is used to show that this item is optional. Normally, including the item and omitting the item produce different effects. The brackets themselves should always be omitted.
[Enter], etc.
These graphics are used to represent 'named' keys on the keyboard. For example, [Enter] represents the Enter key - not the letters E N T E R. Letter and digit keys are represented by the character itself. For example, Q represents the Q letter key.
Control-character
This represents a 'Control code'. The key to press will often be one of the special 'function' keys (listed in Appendix II.2) but holding down [Extend Mode] and then typing character will always work as well.

Contents

Part I: CP/M Plus

1Introduction to CP/M Plus1
1.1Getting started 3
1.2CP/M and the keyboard 4
1.3CP/M and the screen 5
1.4More about CP/M 9
1.5Some practice in using CP/M13
2CP/M Programs25
2.1Suitable software 25
2.2First steps 26
2.3Running ready installed software26
2.4Installing the software 29
2.5Spectrum +3 parameters 29
3Standard 'housekeeping' tasks33
3.1 Assessing the available space 34
3.2 Copying discs 34
3.3 Copying files 36
3.4 Creating files 38
3.5 Editing the command line 40
3.6 Editing text files 41
3.7 Erasing files 43
3.8 Finding the size of a file 44
3.9 Formatting discs 45
3.10Listing the directory 46
3.11Listing a file 47
3.12Organising your discs 48
3.13Protecting your files 49
3.14Renaming files 52
3.15Shortening the command line 53
3.16Switching which disc is read or written56
4Tailoring the Spectrum to your needs57
4.1 Setting up the parallel Printer port 58
4.2 Setting up the RS232 port for a serial printer66
4.3 Using your Spectrum +3 for communications 69
4.4 Configuring the Memory disc 72
4.5 Selecting the appropriate national language 73
4.6 Redefining the keyboard 75
4.7 Redirecting console input and output 80
5The CP/M built-in commands and utilities85
Alphabetical listing of the commands and utilities, with full descriptions and examples of their use.

Part II: Mallard BASIC

1Starting with BASIC129
1.1Entering BASIC 129
1.2Leaving BASIC 129
1.3Using BASIC 130
1.4Giving BASIC commands130
1.5Types of information 131
1.6Chapter review 135
2Starting programming with BASIC137
2.1A first program 137
2.2More complex programs139
2.3Changing a program 140
2.4Chapter review 142
3Real programming143
3.1Designing programs 143
3.2Getting information 144
3.3How information is stored 148
3.4Outputting the results 155
3.5Controlling the output device157
4Writing larger programs165
4.1Compartmentalising a program 165
4.2Sequences and loops 166
4.3Making decisions 168
4.4Stopping the program 172
4.5Organising the program 172
5Manipulating information179
5.1Manipulating numeric information179
5.2Manipulating textual information182
5.3Converting between different types of information185
6Using discs for information storage187
6.1General disc commands 188
6.2Sequential access files180
6.3Random access files 200
7Keyed access files for data bases213
7.1Writing a program using Keyed files 215
7.2Working out the main program 216
7.3Preparatory stage 217
7.4Adding a record 219
7.5Reading a record 223
7.6Deleting an entry 225
7.7Closing the Keyed file 227
7.8Enhancements 229
8Machine level operations239
8.1General information 239
8.2Applying a Patch 240
8.3Loading a machine code program241
8.4Using a machine code program 243
8.5Examples 244

Appendices

I Disc contents247
II CP/M Plus character set249
II.1The complete character set250
II.2The standard CP/M keyboard257
IIITerminal characteristics259
IV BASIC keywords265
V Reference books267
VI Technical description269
VI.1Character devices 270
VI.2Disc driver 275
VI.3Memory organisation 278
VI.4The BIOS 280
VI.5Field installable device drivers317
VII Error messages343
VII.1Disc handling errors 343
VII.2Device errors 344
VII.3CP/M Plus error messages 344

Index Chapter 1