Renumber Subroutine

See all articles from The Plotter v6 n3
Author(s): Glen Ten-Eyck
Publication: The Plotter
Pub Details: The Plotter v6 n3 (Volume 6, Issue 3)
Date: March 1988
Pages: 5

Here is a handy little trick for making subroutines that can be renumbered by simple basic renumber programa. It does away with GO TO’s. At the start of the subroutine, or elsewhere in the program if it is more convenient, define a string with a name that is not used elsewhere or is a throwaway. X$ will be used in the illustration.

9000 LET X$="PEEK 23621+256*PEEK 23622"
9010 LET PPC=VAL X$+20:POKE 23618,(PPC-256*INT (PPC/256)):POKE 23619,INT (PPC/256):POKE 23620,1
9020 PRINT "IT DOES NOT WORK"
9030 PRINT FLASH 1;"IT WORKS!"

These are the rules to use–:

1. Line numbers must advance in a uniform fashion, by 10’s is easiest for me.
2. VAL X$ establishes the current line # from the system variables. The amount that is added or subtracted will the program to the new line number. In this case, add 20 advances the program to 9030 and skips 9020 altogether.
3. 23620 must be POKEd to 1 in order to force the jump to statement 1 of the target line.

Try renumbering this program all that you want. As long as you stay with a spacing of 10, it will work. If you change the line spacing, it will still work if you remember to change the 20 in line 9010 to the appropriate figure (2* line spaces).

I came up with this because the only renumber program that I have does not renumber GO TO’s or GO SUB’ and everybody that writes a handy subroutine writes it at line 9000 on.

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