by Bob Cockroft
One of the major disadvantages of the BASIC language is that it has no provision for erasing more than one line. Even large sections of programs must be erased line by line. This, needless to say, can become quite tiresome.
Well, the days of single line erasing are over! Below is a program that will erase as many lines as you wish. It is called the erase program and hopefully will make deleting delightful. There are no fancy machine language subroutines or little known commands, to make things complex. It works by fooling the computer into thinking that the lines are being erased one by one.
After the program is started, it will ask you for the number of the first and last lines of the block that is to be erased. Once it has these values it will begin to erase. The larger the block you want deleted, the longer it will take. But generally speaking, operation time for this program is nominal. Erasing will appear as a series of numbers being printed in a single column on a number of GRAPHIC mode 0 screens. The cursor will move from the top to the bottom of the column as if the RETURN key were continuously pressed. As far as the computer is concerned, this is what is happening. The column is a list of all possible line numbers within the block you wanted erased. (remember the beginning of the program) With each screen the cursor is POSITIONed at the top. Then, by putting the computer into "RETURN key mode", the cursor is moved down the screen, erasing as it goes. Each new screen is needed to display extra lines when there is a large block to be erased. The obvious question now is: how does one get the computer into "RETURN key mode"? Between locations 832 and 847 dec are some device regulators which are called the Input Output Control Block.(IOCB) These locations can be used to transfer data to other devices as well as to point to the address of the devices routine. POKEing 842 with 13 puts the computer into "RETURN key mode" by setting the auxiliary byte to screen input and output. POKEing 842 with 12 returns the machine to normal.
The "RETURN key mode" can be used for more than erasing. With a method similar to that used in this article, lines of data or any other commands could be added to existing programs without anyone typing them in. With more complex variations the computer could program itself. The only limit to the ends that this type of programming will bring, is your imagination.
You may have noticed that the line numbers for this program are all very high(over 32000). This is done so that the ERASE utility does not interfere with the program in which you want to do the deleting. In order to erase, you must use untokenized files(LIST,ENTER). First, save the ERASE program listed below, using the LIST command, thus creating an untokenized file. Then do the same to the program in which you want to do deleting. Now ENTER both this program and the ERASE utility on top of each other. Finally, type GOTO 31000 on line 1 to make the utility operational.
Soon after the program is started, it will ask you whether you wish to delete the ERASE UTILITY. If you respond `Y' then ERASE UTILITY is deleted. There is no use in having an erasing program if the program itself cannot be easily erased.
31000 GRAPHICS 0:DIM YN$(5):TRAP 31000:? "Delete ERASE UTILITY(Y/N)"
31010 INPUT YN$:IF YN$<>"N" AND YN$<>"Y" THEN POSITION 2,1:? " ":POSITION 2,1:GOTO 31010
31020 POSITION 7,2
31030 ? "First line to DELETE";
31040 INPUT SL
31050 IF SL>30999 THEN 31000
31060 TRAP 31060
31070 POSITION 7,4
31080 ? "Last Line to DELETE";
31090 INPUT EL
31100 IF EL<SL OR EL>30999 THEN 31000
31130 TRAP 31320
31150 REM ** DRAW NEW SCREEN **
31160 FOR GR=0 TO SR
31170 GRAPHICS 0
31180 POSITION 2,5
31190 FOR DAT=0 TO 14
31200 IF L>EL THEN 32120
31210 PRINT L
31230 NEXT DAT
31240 7 "POKE 842,12:GOTO 31270"
31250 POSITION 0,0
31260 GOTO 31500
31270 NEXT GR
31280 GRAPHICS 0
31290 POSITION 10,5
31300 ? "The lines are ERASED"
31310 GOTO 31360
31320 POSITION 3,20
31330 ? "POKE 842,12:GOTO 31270"
31340 POSITION 0,0
31350 GOTO 31500
31360 IF YN$="Y" THEN 31380
31380 GRAPHICS 0
31400 FOR X=31000 TO 31500 STEP 10
31410 POSITION 3,Y
31420 ? X
31440 IF Y<20 THEN NEXT X
31450 ? "POKE 842,12:GOTO 31480"
31460 POSITION 0,0
31470 GOTO 31500
31480 GRAPHICS 0:Y=3:GOTO 31440
31490 GOTO 31440
31500 POKE 842,13
1 REM * CHECK DATA *
10 DATA 5882,544,545,546,547,501,654,243,358,26,713,30,250,215,17,284957,352
31130 DATA 7504,27,719,977,355,112,248,358,506,939,740,4,892,239,33,944,114,297
31300 DATA 7382,269,33,290,892,239,33,658,688,115,644,44,281,620,769,667,898,242
31470 DATA 180,36,30,41,73