This program renumbers the line numbers in any other program in memory. It cannot renumber GO TO and GO SUB statements, but can change line numbers to increment by any step you choose, which is handy if you stick lines in while writing your program so that you don’t get even steps–10, 20, etc.
Most users will want to skip the REM statements and most or all of the PRINT statements. I use a 14-line version. Load this routine before writing a new program, then use it to renumber the lines, adjusting the GO TO and GO SUB statements. It makes a neater product. Don’t forget to include a STOP in your program. This program will not work on programs loaded from tape because loading erases everything in RAM.
You can renumber any program in memory, except this one, if you know the address of the first line number. Let S=1 less than that address. Since the first user program always starts at 16424, I started S at 16423.
9000 REM RENUMBER FIRST PROGRAM. PROGRAM MUST END WITH STOP. RENUMBER GO TO/GO SUB YOURSELF. DO NOT ATTEMPT TO RENUMBER THIS PROGRAM.
9010 LET S=16423
9020 PRINT "START WITH FIRST LINE AT?",
9030 INPUT N
9040 PRINT N
9050 LET F=N
9060 PRINT
9070 PRINT "RENUMBER BY?",,
9080 INPUT D
9090 PRINT D
9100 GO SUB 9200
9110 LET S=S+1
9120 IF PEEK(S)=118 THEN GO SUB 9200
9130 IF PEEK(S)=248 THEN GO SUB 9300
9140 GO TO 9110
9200 REM SUBROUTINE TO POKE NEW LINE NUMBER
9210 POKE (S+1),(N/256)
9220 POKE (S+2),(N-(N/256)*256)
9230 LET N=N+D
9240 RETURN
9300 REM END OF PROGRAM
9310 PRINT
9320 PRINT "FIRST PROGRAM WAS"
9330 PRINT " RENUMBERED FROM ";F;" BY ";D
9340 PRINT
9350 PRINT "LAST LINE NUMBER= ",(N-D)
9399 STOP
SYNTACTIC SUM= -27966
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.