On several occasions, I have had to delete a large block of Basic program statements from an existing program. For example, I developed a loader program to process “pseudo machine code” into actual absolute address machine language code. The loader is written in Basic and is several hundred statements in length. After the machine language code is debugged and running properly, I only want to retain the REM statements containing the machine code, not the loader. Deleting the loader program one line at a time is a tedious, time consuming process. I decided there had to be a better way.
Closer inspection of the chapter on system variables in the manual, uncovered the word NXTLIN at address 16425. The definition is:
SX2 16425 NXTLIN Address of next program line to be executed.
Suppose I put some statements just before the first line I wanted to delete, and some other statements just after the last line I wanted to delete. I should be able to calculate the total length of all the lines in between. Then I could POKE this length into a REM statement at the beginning of the block. The REM statement would then include all the statements I wished to delete. Deletion of the REM statement would delete the entire length. I thought this would work, since I had learned through experimentation that statement deletions are based on length only, not the ending ENTER character.
It does work. Figure 1 shows sample coding to delete lines 200 through 5000. The statements with line numbers which are not multiples of 10 are the statements necessary to perform the deletion. After adding the necessary statements, type in: GOTO 5001 and hit ENTER. You will stop with 9/199. Now delete lines 191, 192 and 5002. Lines 200-5000 will be deleted and also all the coding used to delete them.
Figure 1. Sample Deleting Lines 200-5000.
10
. (10-190 ARE LINES
. TO BE KEPT)
190
191 LET S=PEEK 16425+256*PEEK 16426+3
192 REM
193 LET L=E-S-1
194 POKE S,INT (L/256)
195 POKE S-1,L-256*PEEK S
199 STOP
200
. (200-5000 ARE LINES
. TO DELETE)
5000
5001 LET E=PEEK 16425+256*PEEK 16426
5002 GOTO 191
5010
. (5010-9990 ARE LINES
. TO BE KEPT)
9990
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.