Chapter 1: Introduction

BASin

Chapter 1: Introduction

Before you start programming, you should be aware of the difference between commands and instructions. Commands are obeyed straight away, and instructions begin with a line number and are stored away for later. You may also be aware of some simple commands: PRINT, LET, and INPUT (which can be used on all machines that use BASIC), and BORDER, PAPER and BEEP (which are used on the Spectrum).

This BASIC manual details various programming concepts and commands, telling you exactly what you can and cannot do. You will also find some exercises at the end of each chapter. Don't ignore these; many of them illustrate points that are hinted at in the text. Look through them, and do any that interest you, or that seem to cover ground that you don't understand properly.

Whatever else you do, keep using the computer. If you have the question "What does it do if I tell it such and such?" then the answer is easy: type it in and see. Whenever the manual tells you to type something in, always ask yourself, "what could I type instead?", and try out your replies. The more of your own programs you write, the better you will understand the computer.

At the end of this programming manual are some appendices. These include sections on the way the memory is organised, how the computer manipulates numbers, and a series of example programs.

The keyboard

BASin uses the standard PC keyboard and a version of the ZX Spectrum 128 editor. The various modes and single-key entry system from the original 48K Spectrum do not apply. See The keyboard for information on entering special characters that do not appear on a PC keyboard.

While you type, your position is indicated by the cursor, a flashing block that shows where the next character from the keyboard will be inserted. The cursor can be moved about with the four directional arrow keys: it will automatically jump to the end of a line rather than wander into unused space.

If any key is held down for more than about 2 or 3 seconds, it will start auto-repeating.

When Enter is pressed, the current line is executed, entered into the program, or used as INPUT data as appropriate, unless it contains a syntax error. In this case the cursor changes colour (from blue to red) and moves to the approximate position of the error, and the computer sounds a beep.

As program lines are entered, a listing is built up in the editor. You can use move the cursor onto any line in the listing with the keys and , and edit the existing line by typing your changes and pressing Enter.

When a command is executed or a program run, output is shown in a separate display window. Error reports may appear in the bottom part of the display window or in a message box. These reports are described in Appendix B.

The Esc key (and, in certain circumstances, Space) acts as a break, stopping the computer with report D or L. This is recognised:

  1. at the end of a statement while a program is running, or
  2. while the computer is loading, saving, or printing.

The display window

This has 24 lines, each 32 characters long, and is divided into two parts. The top part is at most 22 lines and displays either a listing or program output. When printing in the top part has reached the bottom, it all scrolls up one line; if this would involve losing a line that you have not had a chance to see yet, then the computer stops with the message scroll?. Pressing any of the keys n, Space or Esc will make the program stop with report

D BREAK - CONT repeats

...any other key will let the scrolling continue. The bottom part is used for inputting commands, program lines, and INPUT data, and also for displaying reports. The bottom part starts off as two lines (the upper one blank), but it expands to accommodate whatever is typed in. When it reaches the current print position in the top half, further expansions will make the top half scroll up.

Chapter 2