Previous chapter Index Chapter 1

Part II: Mallard BASIC


Introduction

This part of the user guide describes how to use Locomotive Software's Mallard BASIC interpreter to write and use BASIC programs on your Spectrum +3.

BASIC was originally designed many years ago as a programming language that was simple to learn, as an aid to teaching computer programming. There are now many versions of BASIC, developed from the original. You are probably already familiar with the Spectrum BASIC supplied on your machine.

Mallard BASIC is a very different type of BASIC to Spectrum BASIC. They use a number of the same commands but, overall, the sort of facilities they provide are very different. Spectrum BASIC is designed to exploit the features of the Spectrum itself - and so contains a number of commands that produce graphics on the Spectrum's screen or sounds out of its loudspeaker.

Mallard BASIC concentrates on data processing and file handling - which is less spectacular than graphics etc. but gives it a significant advantage over Spectrum BASIC. Mallard BASIC and programs written in Mallard BASIC can be run on a wide range of computers without any re-writing; Spectrum BASIC and Spectrum BASIC programs can only be run on the Spectrum.

BASIC is very versatile and can be used to perform most tasks involving manipulating numbers and text. The simplest use of BASIC is as a sophisticated calculator, but you can quickly move on from this to using BASIC to write programs.

Programs can perform an infinite range of tasks, from simple things such as totalling sequences of figures to complex tasks such as maintaining a personnel file, calculating payrolls or performing statistical analyses. Mallard BASIC has a very unusual facility (for BASICs on microcomputers) for indexing data stored in a file, and automatically keeping this index in alphabetical order. This is a very useful facility to have in a program that works with a database.

You can use programs written by others (of which a wide range are available) or write your own, once you have learned how to program.

The copy of BASIC on your CP/M disc is set up ready for use on your machine. To use it, you just have to load CP/M and type the command BASIC [Enter]. You then have access to all the facilities of BASIC described in this manual - including the screen-based editor which displays your program lines as you change them.

In this part of the user guide, we give a gentle introduction to programming in BASIC, aimed principally at new users who have never written a program before. This takes you from using BASIC as a simple calculator, through writing simple programs (for example, to print the result of a simple calculation), to preparing fully-featured programs that manipulate complex data files.

Many of the operations we describe are concerned with manipulating numbers and text, but not all. For example, we show you how to position the cursor on the screen or clear the screen and how to control the printer from your program - setting the page length, positions of tabs and even resetting the printer from inside your BASIC program. We also show you how to incorporate machine language routines in your program and how to call up external routines, such as those within the operating system itself.

By the time you have worked through even just the first five chapters, you should be able to write simple but useful BASIC programs. If you need more help to understand programming, you should turn to one of the many excellent tutorial texts that are available. Ask your dealer for details.

If you have used other standard BASICs, you probably won't need to read this section in any detail, except perhaps for Chapter 7 which describes the very powerful Keyed File Handling (JETSAM) provided by Mallard BASIC. Instead, we would recommend you to read 'Mallard BASIC: Introduction and Reference' which describes Mallard BASIC, fully and accurately.

If your experience of programming is just Spectrum BASIC, we recommend you to read from Chapter 3 on really quite carefully as there are many significant differences between Mallard BASIC and Spectrum BASIC. Even commands with the same name don't work identically in all cases: DIM statements, for example, are completely different. Another difference to note is that the LET keyword, which is obligatory in Spectrum BASIC, is optional in Mallard BASIC and in practice is hardly ever used. Your experience of using Spectrum BASIC should however make Mallard BASIC very easy to pick up.

Conventions

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

INPUT, PRINT, etc.
The names of BASIC's commands and functions (INPUT, PRINT etc.) are shown in this manual in capital letters. It does not matter whether you type these names as capitals or as lower case letters; they are automatically converted to capitals when BASIC stores the program.
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.
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.
[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.

IMPORTANT: Some of the characters that have special meaning in BASIC (specifically, #, \ and ^) are language dependent - that is, the character that is displayed depends on which national language version of CP/M you are using. Throughout this section of the user guide we have assumed that you are using CP/M as supplied and are therefore using the US character set (language 0). If you have selected the English character set (language 3), for example, you will need to substitute £ for # in every command that we give in this book. (#s in existing programs will automatically be displayed as £s.)

The differences between the various national language versions of CP/M are explained in Part I (Section 4.5). They can also affect your how your programs appear when they are listed on a printer.


Previous chapter Index Chapter 1