ebook img

Archimedes 400 Series BBC BASIC Guide PDF

450 Pages·1988·21.09 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Archimedes 400 Series BBC BASIC Guide

The Archimedes Series BBC BASIC GUIDE Copyright © Acorn Computers Limited 1988 Neither the whole nor any part of the information contained in, nor the product described in, this guide may be adapted or reproduced in any material form except with the prior written approval of Acorn Computers Limited. The product described in this guide and products for use with it are subject to continuous development and improvement. All information of a technical nature and particulars of the product and its use (including the information and particulars in this guide) are given by Acorn Computers Limited in good faith. However, Acorn Computers Limited cannot accept any liability for any loss or damage arising from the use of any information or particulars in this guide. All correspondence should be addressed to Customer Support and Service, Acorn Computers Limited, Fulboum Road Cherry Hinton Cambridge CBl 4JN. ACORN, ARCHIMEDES and ECONET are trademarks of Acorn Computers Limited. Within this publication, the term 'BBC' is used as an abbreviation for 'British Broadcasting Corporation'. First published 1988 Issue 1 Published by Acorn Computers Limited ISBN 1 85250 052 2 Part number 0483,00 l ii Contents About the BBC BASIC Guide Command mode 3 Simple programming 7 Variables and expressions 19 Numeric variables 21 Bases 27 String variables 33 Arrays 41 Outputting text 51 Inputting data 57 Control statements 67 Procedures and functions 83 Data and command files 97 Screen modes 101 Simple graphics 111 Complex graphics 121 Graphic patterns 131 Viewports 141 Sprites 145 Teletext mode 149 Sound 155 Accessing memory locations 161 Contents iii Error handling and debugging 165 Keywords 171 Keywords: Numerical 173 Keywords: Trigonometric 185 Keywords: Logical 197 Keywords: Program construction 203 Keywords: Program statements 221 Keywords: Variables 249 Keywords: Error handling 259 Keywords: Input/Output 267 Keywords: Character/String handling 283 Keywords: Sound 293 Keywords: File commands 301 Keywords: Assembly language 313 Keywords: Structures 331 Keywords: Graphics 347 YOU commands 373 The BASIC screen editor 383 Appendix A-Minimum abbreviations 401 Appendix B -Error messages 407 Appendix C-lnkey values 411 Appendix D- Plot codes 415 Appendix E -VDU commands 417 Appendix F -Operating system commands 421 Appendix G- *FX commands 423 Appendix H- BBC BASIC's history 427 Index 435 Contents iv About the BBC BASIC Guide BBC BASIC is onl! of thl! 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 :my action involving the computer and the devices connected ro it. Several examples of programs written in BBC BASIC are provided on the Applications suite. A brief history of BBC BASIC is provided in the Appendices. 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 :.creen, 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(*). The first chapters of this guide explain how to program in BASIC, and introduce many of the commands provided by the language. A complete lbt of the BASIC keywords, grouped by function, is given in the chapters headed Keywords:. The last two chapters, and the appendices, list the features provided by the operating system, and the commands available to control them. The BASIC screen editor is also described. About the BBC BASIC Guide Conventions used in The following conventions arc applied throughout this guide: this guide • Specific keys to press are denoted as <Ctrl>, <Delete> anJ so on. • Instructions which require you to pre~ a comhmation of keys are shown thus: <Shift> <Break> means hold down the <Shift> key and press and release the <Break> key. • Text you type on the keyboard anJ text that is dtsplayed on the screen appear~ as follows: PRINT "Hello" • Classe~ of item arc shown in italics: For example, tn the descriptions of BASIC keywords, you might see something like: LET var = expression where var and expression would he replaced with actunl instances, eg: LET a$="hello" • Items within square brackets [] are optional. For example, GCOL [expr,] expr means that the first expr and the comma after it do not have to be included. • After entering any text, press <Return> to tell the computer that you have completed the line and that you want the computer to act upon it. • Extra spaces are inserted into program listings to aid clarity, but need not be typed in. • Program ltstings are indented to illustrate the structure of the program:.. If at any time you wish to interrupt a program the computer is executing you can do so safely by pressing <E~c> . Do not he afraid to experiment. Try modifying the programs liMed in this book and writing new ones of your own. About the BBC BASIC Guide 2 Command mode Entering BASIC To activate BASIC, display the Task Manager menu (click the centre mouse button over the 'A' icon at the hottom righthand corner of the desktop), and type BASIC in the New Task submenu box. Press <Return>, and a RASIC window will open on the screen. Alternatively, press <F12> from the desktop, then type BASIC from the command line. Infonnation about the *BASIC command may be found in the chapter Keywords: Program construction. You can configure your computer to enter BASIC automaucally when it is switched on. To do this, type the command: *configure language 4 then press <Ctrl> <Break> . Leaving BASIC To leave BASIC, type *QUIT, the press <Return> twice to get back to the desktop. When you enter BASIC it •~ 10 command or interactive mode (sometimes this is rermed immediate mode). Th1s means that you can type commands and the computer responds straight away. For example, if you type PRINT "Hello" the computer displays the following on the screen: Hello Command mode 3 PRINT is an example of a keyword which the computer recognises. It instructs the computer to display on the screen whatever follows the PRINT statement enclosed in quotation marks. Keywords arc always written in upper case letters (capitals). If you make a mistake, the computer may not be able to make sense of what you have typed. For example, if you type: PRINT "Hello the computer responds with the message: Missing " Thi~ is an error message. It indicates that the computer cannot obey your command because it does not follow the rules of BASIC (in this case because the computer could not find a second quotation mark). If PRINT is followed by any series of characters enclosed in quotation marks, then these characters arc displayed on the screen exactly as you typed them. Thus: PRINT "12 - 3" produces the output: 12 - 3 PRINT, however, can abo be used to give the result of a calculation. For example, typing PRINT 12 - 3 produces the output: 9 In th1s case, because the sum was not enclosed in quotation marks, the computer performed the calculation and displayed the result. Similarly, multiplication and division can be performed using the symbols * and /. For example: PRINT 12 * 13 PRINT 111 I 11 Command mode 4 Some commands, although they have an effect on the computer, do not give evidence that anything has changed. If, for example, you type LET FRED = 12 nothing obvious happens. Nevertheless, the computer now knows about the existence of a variable called FRED which has the value 12. A variable is a name which can have different values assigned to it. It is described in more detail later in this manual. Now if you type PRINT FRED / 3 the computer responds by displaying the number 4. The program below illustrates how you can give commands to produce some graphics on the screen: MODE 12 CIRCLE FILL 600,500,100 The MODE command sets up the computer to produce high resolution graphics (640 by 256 dots in 16 colours). It also clears the screen. The CIRCLE FILL command tells the computer to draw a circle at a position 600 dots across from the left of the screen and 500 dots up from the bottom. This is near the centre of the screen because the screen is 1280 units across and I 024 units high. The third number tells the computer how big the circle should be, in this case giving a radius of 100 dots. >CIRCLE FILL 600,500.100 >_ Command mode 5

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.