In Sync: 2068 Line Renumber Routine

See all articles from T-S Horizons n16

When TIMEX redesigned the Spectrum, the software engineers rewrote and expanded the original 16K ROM. They added several new features that increased the versatility of the 2068. They did, however, make some notable omissions. The most unfortunate of which is the lack of a renumbering routine. I have a machine code program that renumbers the entire BASIC program, including the statement numbers after GOSUB and GOTO commands. After using this routine for a while, I found it very inconvenient to renumber the entire program when I only wanted to change the line numbers in a subroutine.

Being a die-hard programmer, I wrote a BASIC program that will renumber specific sections of a program. It does not change the line numbers after GOSUB and GOTO commands, but you can’t have everything, especially when programming in BASIC. The program is very straightforward in its operation, prompting the programmer for the necessary information.

To use the program, enter the program fron the listing provided, SAVEing it to tape before you test it. If you made a mistake in the entry of the program, it will destroy itself the first time you use it. After you have an error free copy of the program then you can SAVE it on a cassette for future use. You can set up a test program of REM statements and follow the instructions in the next section to test the program.

Instructions for use:

Load the program you are working on into the 2068, then MERGE the renumbering program onto the end of yours. To use the program, type GOTO 9980. If you use RUN 9980, you will erase any variables you might have stored in memory. The first prompt requests the line number you wish to start the renumbering process at. Enter the desired number then press the ENTER key.

The program then requests the desired values for the number to start the renumbering with, the amount you want the line numbers to increment and the line number you want the program to stop renumbering at. The last prompt enables you to cancel the renumbering process by entering “0”. If you enter any other value or letter, the program will RUN using the values you entered previously.

If you enter any line number greater than 9979 in response to the “Stop at line number?” prompt, the program stops automatically at 9979. Try entering “0” for the value to start renumbering with and for the line increment. Be warned, however, that this will make the program uneditable both to hackers AND the programmer! Also note that if you have a command that says, say “GOTO 100” and you have changed line 100 to “0” or any other number, your program will not work. You HAVE to maintain all of the line numbers that are accessed by GOSUB or GOTO commands. In any case, it takes some playing around with this program before you get to know exactly what it will do.

The only limitation the renumbering routine places on the programmer is that you can’t use any line number above 9979. It is compatible with TIMEX and SINCLAIR ROM chips installed in your machine. However, if you have the misfortune to be programming on a ZX/81, you will have to rewrite the program to comply with the syntax of that computer. You will also have to change the following numbers in line #9990 (23635 to 16509 and 23636 to 16510).

I hope the renumbering routine makes your programming easier and more rewarding. Next time I’ll have a machine code routine that lets you save and recall a graphics screen INSTANTLY. TSH

9980 INPUT "Start renumbering at? ";startline
9981 PRINT "Start renumbering at line; ";startline
9982 INPUT "Start renumbering with? ";startnum
9983 PRINT "Start renumbering with; ";startnum
9984 INPUT "Line increment? ";lineinc
9985 PRINT "Line increment; ";lineinc
9986 INPUT "Stop at line number? ";stopline
9987 PRINT "Stop at line number; ";stopline
9988 INPUT "Press any key to continue, ""0"" to stop; ";stop
9989 IF stop=0 THEN STOP
9990 LET startloc=PEEK 23635+256*PEEK 23636
9991 LET linenum=(PEEK startloc)*256+PEEK (startloc+1)
9992 LET length=PEEK (startloc+2)+PEEK (startloc+3)*256
9993 IF linenum<startline THEN GO TO 9998
9994 IF linenum>=stopline OR linenum>9979 THEN STOP
9995 POKE startloc,INT (startnum/256)
9986 POKE (startloc+1),startnum-(INT (startnum/256))*256
9997 LET startnum=startnum+lineinc
9998 LET startloc=startloc+4+length
9999 GO TO 9991

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.