Mallard BASIC: Introduction and Reference
Total Page:16
File Type:pdf, Size:1020Kb
Mallard BASIC For the Amstrad PCW8256/8512 & PCW9512 LOCOMOTIVE Introduction SOFTWARE and Reference Mallard BASIC Introduction and Reference The world speed record for a steam locomotive is held by LNER 4-6-2 No. 4468 “Mallard”, which hauled seven coaches weighing 240 tons over a measured quarter mile at 126 mph (202 kph) on 3rd July 1938. LOCOMOTIVE SOFTWARE © Copyright 1987 Locomotive Software Limited 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 Mallard BASIC 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, Mallard BASIC is subject to continuous development and improvement, and it is acknowledged that there may be errors or omissions in this manual. Locomotive Software reserves the right to revise this manual without notice. Written by Locomotive Software Ltd and Ed Phipps Documentation Services Produced and typeset electronically by Locomotive Software Ltd Printed by Grosvenor Press (Portsmouth) Ltd Published by Locomotive Software Ltd Allen Court Dorking Surrey RH4 1YL 2nd Edition Published 1987 (Reprinted with corrections May 1989) ISBN 185195 009 5 Mallard BASIC is a trademark of Locomotive Software Ltd LOCOMOTIVE is a registered trademark of Locomotive Software Ltd AMSTRAD is a registered trademark of AMSTRAD plc IBM is a registered trademark of Intemational Business Machines Corp CP/M-80, CCP/M-86 and MP/M-86 are trademarks of Digital Research Inc MS-DOS is a trademark of Microsoft® Corporation VT52 is a trademark of Digital Equipment Corp Preface This book describes how to use Locomotive Software's Mallard BASIC interpreter to write and use BASIC programs on your Amstrad PCW. 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 this original. Mallard BASIC is a powerful modern BASIC with a number of significant improvements. In particular, 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. 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. 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 (Retay]. 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. About this manual This manual is designed to help you use Mallard BASIC. It is divided into two parts: Part I: A gentle introduction, suitable for new users including those who have never written a computer program before. Part II: A reference section containing a detailed description of all the facilities of BASIC. Mallard BASIC: Introduction The Introduction takes the user 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. The Reference section describes BASIC in detail. It is aimed at experienced users who have used other BASICs before or who have read and understood the Introduction. Many of the operations described in this manual 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. For example, we show you how to use these techniques to generate graphics effects by using GSX, the graphics extension to CP/M. If you are entirely new to BASIC Start by reading through the Introduction, working through the examples on your computer as you do so. You may, if you wish, just read up to the end of Chapter 5 if you don't want to work with files initially. By the end of the Introduction, you should be able to write simple but useful BASIC programs with occasional help from the Reference section. To discover how to use the full range of facilities offered by Mallard BASIC, you should then read Part II. Although Part I covers the most useful facilities of BASIC, it does so at the fairly elementary level, with the emphasis on understanding rather than complete technical detail. Part II gives the definitive description of Mallard BASIC. If after reading Part I 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 programmed in BASIC before You probably won't need to read Part I in any detail, except perhaps for Chapter 7 which describes the very powerful Keyed File Handling (JETSAM) provided by Mallard BASIC. Concentrate instead on the Reference section which is intended to describe Mallard BASIC, fully and accurately. This includes in Chapter 10 the formal specification of each of the commands and functions in keyword order. Mallard BASIC: Introduction Different versions of Mallard BASIC Mallard BASIC is available in different versions for use with different operating systems working on different processors. In particular, there are separate versions for 8-bit processors like the Z80 and 8080 (Mallard-80), for 16-bit processors like the 8088 and 8086 (Mallard-86); and there are multi-user versions of Mallard-86 for use on networks of 16-bit machines. There are also Run-Only versions available. Part I of this manual is tailored to the version of Mallard BASIC supplied on the Amstrad PCW machines, but Part II can be used with any version of Mallard BASIC. However, you should note that a few of the commands only have an effect in certain versions. Where this is the case, this is mentioned in the text. At the time of printing, the following versions are available: 8-bit Single User version (Mallard-80) for CP/M 2.2 and CP/M Plus 16-bit Single User versions (Mallard-86) for MS-DOS version 1 for MS-DOS version 2 and above for CP/M-86 16-bit Multi-User versions (Multi-User Mallard-86) for MS-DOS 3.2 and above with MS-NET for TurboDOS for Concurrent CP/M and Concurrent DOS Note that Multi-User versions are only available for 16-bit machines. 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. They are also always displayed in capitals when programs are listed. 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. Mallard BASIC: Introduction see GOTO, see FIND$, etc. Further information is given where the given topic (GOTO, FIND$ etc.) is described. Use the index to find the relevant page to look at. 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. The majority of descriptions are explained in the accompanying text. The remainder are self-explanatory. The common descriptions are listed in the introduction to Chapter 10 in Part II, the overview of BASIC's commands and functions. [items in slanted brackets] Slanting brackets round an item are 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. , Cc. These graphics are used to represent individual keys on the keyboard. For example, represents the Return key — not the letters RETURN. (Additional conventions used in the Reference Section are described at the beginning of Part IT.) Mallard BASIC; Introduction Part I INTRODUCTION Mallard BASIC CONTENTS 1. Starting with BASIC 1.1 Entering BASIC LZ Leaving BASIC L.3 Using BASIC 1.4 Giving BASIC commands iS Types of information 1.6 Chapter review rH = NWNnNNR 2.