Contents / Part 2 / Previous chapter / Next chapter / Index


7 AUTO, DELETE, REM, RENUMBER

BASIC provides a number of facilities to help the user to enter programs into the computer and to modify programs already there. As you will know by now, it is usual to use line numbers 10, 20, 30, 40 etc., for programs. This leaves gaps where the user can insert extra lines later on - for example, he or she might insert lines 11, 12, 13 and 14. When typing in a line of program the user types in the 'line number" first and then the rest of the line. For example,

10 PRINT "THIS IS A PROGRAM"

The command AUTO instructs the computer to "offer" the line numbers automatically to the user. As an option you can tell the computer to start offering lines from any number. Thus AUTO 300 would make the computer produce line number 300, then 310, then 320, etc. There are other options, too, which are explained on page 213.

The command DELETE allows the user to delete a group of lines from his or her program. When you are writing a long program you quite often need to be able to delete a large chunk of it. The keyword DELETE is followed by two numbers which give the first and last lines that you wish to remove. Thus

DELETE 150,330

would delete all the lines with numbers between 150 and 330.

Single lines can be removed by typing in the line number and pressing RETURN.

REM is a very useful statement. It enables you to put remarks in your program to remind you (not the computer) what is going on. If you are developing a big program - or loading a simple program that you have not used for some time - it is very easy to forget how it works or what it does. Normally people place several REMs at the start of a program to give general information and then put a REM at major points further down the program. See pages 232 or 264 for examples.

Once you have entered a program you will very often find that the line numbers are no longer in a neat sequence. As we have seen the command RENUMBER makes the computer go through the whole program changing all the line number so that they start at line 10 and increase by 10 for each successive line. Certainly, when you have finished a program it is a good idea to RENUMBER it so that it looks tidy. If you have a program in the computer try

RENUMBER

and then LIST the program to see the effect. After that try

RENUMBER 900,100

and you will see, when you list the program, that the computer has renumbered the whole program but the new variation has line numbers starting at 900 and this time increasing by steps of 100.

It is possible to put more than one statement on a line. For example, the two statements

CLS (clear the screen)

PRINT "HELLO"

can be put on one tine, so long as the individual statements are separated by colons, thus:

CLS : PRINT "HELLO"

You can put as many statements on a line as you like so long as the line has less than about 230 characters. The argument for using "multiple statement lines" is that it saves some memory space and may make the program work a little faster. But against that you will notice that it becomes much more difficult to follow the program when you list it (see page 98).

Exit: BBC Microcomputer User Guide; Kasoft Typesetting; Archer


The BBC Microcomputer User Guide was written by John Coll and edited by David Allen for the British Broadcasting Corporation.

Optical character recognition and original formatting effort by Mark Usher.

HTML version maintained by: Kade "Archer" Hansson; e-mail: archer@dialix.com.au

Last updated: Monday 12th February 2001