30 6 Sample programs Most of the rest of this book is concerned with introducing the various parts of the BBC BASIC language which the computer understands and other features of the machine. But first, here are a few complete programs which you can try to type in yourself. They must be typed in accurately and can then be run. If a program fails to run properly, then you probably typed a line in incorrectly – for instance, you may have typed ; when you should have typed : or typed O instead of 0 . Most of the sample programs are too big to fit all of the lines on the screen.
If you LIST a program you have typed in, for example to check that you have made no mistakes, you may find that the lines you want to look at disappear off the top of the screen. To prevent this you can specify the range of lines you want to be listed. For example LIST 100,200 will only list those lines numbered between 100 and 200. Alternatively you can enter ‘paged mode’ by pressing CTRL N (hold down CTRL and press N ). In this mode the listing will stop after every ‘page’ and will continue only when you press the SHIFT key. Paged mode is switched off by pressing CTRL O and you should always remember to do this after you have listed the program.
Typing in programs will help you to get a feel for the keyboard and, if you save them on cassette after you are satisfied that they do run properly, will enable you to start building up a library of them. Learning to use the computer is a little like learning to drive a car – when you first start you find that there are an enormous number of things to think about all at one time. Many of the things you come across from now on will be bewildering at first, but as you get further into the book and as you gain experience in using BASIC, the various parts of the jigsaw puzzle should begin to fall into place.
So don’t worry if, for instance, some of the comments about the following programs are difficult to understand at first. Note: In the program listings which follow, extra spaces have been inserted between the line numbers (10,20, etc) and what follows on each line. This is to improve the readability of the programs. However, although it will do no harm, there is no reason to type in any spaces after the line number. For example in the first program, called POLYGON, when entering line 250, all you need to type is 250MOVE 0,0