Contents / Part 2 / Previous chapter / Next chapter / Index
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
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
and then LIST the program to see the effect. After that try
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)
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).