--- title: "Renumber (Syntax)" id: 77760 type: "computer_media" slug: "renumber-syntax" url: "http://localhost/computer_media/renumber-syntax/" markdown_url: "http://localhost/computer_media/renumber-syntax.md" published_at: "2026-11-18T16:43:07+00:00" modified_at: "2026-11-18T16:43:07+00:00" featured_image: url: "http://localhost/wp-content/uploads/2026/11/renumber-syntax-1.png" excerpt: "A BASIC renumbering utility that also fixes the line numbers in GOTO and GOSUB statements, with two small machine code helpers." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "ZX81" slug: "zx81" taxonomy: "post_tag" url: "http://localhost/tag/zx81/" model: - name: "Sinclair ZX81" slug: "zx81" taxonomy: "model" url: "http://localhost/model/zx81/" - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" indiv: - name: "C. C. Stalder" slug: "c-c-stalder" taxonomy: "indiv" url: "http://localhost/indiv/c-c-stalder/" genre: - name: "Renumber" slug: "renumber" taxonomy: "genre" url: "http://localhost/type/renumber/" media_type: "Program" programmers: - name: "C. C. Stalder" slug: "c-c-stalder" taxonomy: "indiv" url: "http://localhost/indiv/c-c-stalder/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Renumber%20%28Syntax%29%20%281984%29%28Stalder%2C%20C.%20C.%29%28TS1000%29%28US%29%28Program%29.zip" mediadate: "1984" images: - url: "http://localhost/wp-content/uploads/2026/11/renumber-syntax-1.png" - url: "http://localhost/wp-content/uploads/2026/11/renumber-syntax-2.png" - url: "http://localhost/wp-content/uploads/2026/11/renumber-syntax-3.png" article_media: - id: 19882 title: "Renumber" type: "article" url: "http://localhost/article/renumber/" media_type_tags: "Renumber" license: false --- # Renumber (Syntax) RENUMBER renumbers all or part of a BASIC program and corrects the destination line numbers in GOTOs and GOSUBs. It sits in lines 9724-9999, so load it first and type your program in front of it (or merge it with a program of up to about 12,000 bytes whose lines stop at 9722). Start it with RUN 9734. Enter the lowest and highest lines to renumber (0 renumbers the whole program), the new number for the first line and the step, then press R to run, M to change the answers or Q to quit. It is written mostly in BASIC, so it is slow. Before you LOAD it, set RAMTOP to 32512 with POKE 16389,127, POKE 16388,0 and NEW. The program autostarts and POKEs two machine code routines (31 bytes) from a string into 32512-32542: one calls the ROM “make room” routine when a new line number is longer than the old one, the other lets you erase RENUMBER. To erase it, GOTO 9996 and then 9724 ENTER. A GOTO or GOSUB whose destination doesn’t start with a digit is left alone. Published in Syntax January 1984 ([Renumber](https://timexsinclair.com/article/renumber/)). ## Source Code ``` 9724 STOP 9725 REM ****RENUMBER**** 9726 REM BY C. C. STALDER 9728 REM >>NOTE<< THIS ENTIRE PROGRAM LINES 9724 TO 9999 CAN BE DELETED BY TWO COMMANDS: GOTO 9996 ENTER 9724 ENTER 9730 REM 9732 REM RESERVE SPACE AT "VARS"FOR CONVERTING EACH DESTINATION LINE NUMBER TO FLOATING POINT 9734 CLS 9736 CLEAR 9738 LET ND=0 9740 PRINT "LOWEST LINE TO RENUMBER? " 9742 PRINT "TO RENUM ENTIRE PROGRAM, ENTER 0" 9744 INPUT LL 9746 IF LL<0 OR LL<>INT LL OR LL>9722 THEN GOTO 9952 9748 IF LL<>0 THEN PRINT AT 0,26;LL;AT 3,0; 9750 IF LL<>0 THEN GOTO 9762 9752 PRINT AT 0,26;"ALL";AT 3,0; 9754 LET LL=256*PEEK 16509+PEEK 16510 9756 LET HL=9722 9758 GOTO 9770 9762 PRINT "HIGHEST LINE TO RENUMBER? "; 9764 INPUT HL 9766 IF HL<=LL OR HL<>INT HL OR HL>9722 THEN GOTO 9952 9768 PRINT HL 9770 PRINT ,,"NEW NUMBER FOR LOW LINE? "; 9772 INPUT NL 9774 IF NL<1 OR NL<>INT NL OR NL>9722 THEN GOTO 9952 9776 PRINT NL 9778 PRINT ,,"STEP SIZE DESIRED? "; 9780 INPUT SZ 9782 IF SZ<1 OR SZ<>INT SZ THEN GOTO 9952 9784 PRINT SZ 9786 PRINT ,,"CHOOSE:..(R)UN..(M)ODIFY..(Q)UIT" 9788 PAUSE 4E4 9790 LET K$=INKEY$ 9792 IF K$="R" THEN GOTO 9812 9794 IF K$="M" THEN GOTO 9734 9796 IF K$="Q" THEN GOTO 9992 9798 GOTO 9790 9812 LET SA=16509 9814 IF 256*PEEK SA+PEEK (SA+1)=LL THEN GOTO 9826 9816 IF 256*PEEK SA+PEEK (SA+1)>LL THEN GOTO 9952 9818 LET SA=SA+4+PEEK (SA+2)+256*PEEK (SA+3) 9820 GOTO 9814 9826 LET OP=16509 9828 IF 256*PEEK OP+PEEK (OP+1)>9722 THEN GOTO 9940 9830 LET LA=OP+4 9832 IF PEEK LA=250 THEN GOTO 9840 9834 IF PEEK LA=236 OR PEEK LA=237 THEN GOTO 9848 9836 LET OP=OP+4+PEEK (OP+2)+256*PEEK (OP+3) 9838 GOTO 9828 9840 LET LA=LA+1 9842 IF PEEK LA=126 THEN LET LA=LA+6 9844 IF PEEK LA=118 THEN GOTO 9836 9846 IF PEEK LA<>236 AND PEEK LA<>237 THEN GOTO 9840 9848 LET LA=LA+1 9850 LET D$="" 9852 FOR N=LA TO LA+4 9854 IF PEEK N=126 THEN GOTO 9862 9856 IF PEEK N<28 OR PEEK N>37 THEN GOTO 9836 9858 LET D$=D$+CHR$ PEEK N 9860 NEXT N 9862 IF VAL D$HL THEN GOTO 9836 9864 LET DC=0 9866 LET DP=SA 9868 IF VAL D$<=256*PEEK DP+PEEK (DP+1) THEN GOTO 9880 9870 LET DP=DP+4+PEEK (DP+2)+256*PEEK (DP+3) 9872 LET DC=DC+1 9874 GOTO 9868 9880 LET ND=DC*SZ+NL 9882 LET X$=STR$ ND 9884 IF LEN X$HL THEN GOTO 9992 9942 POKE SA,INT (NL/256) 9944 POKE (SA+1),NL-256*PEEK SA 9946 LET NL=NL+SZ 9948 LET SA=SA+4+PEEK (SA+2)+256*PEEK (SA+3) 9950 GOTO 9940 9952 CLS 9954 PRINT "INVALID NUMBER. PRESS ENTER AND START OVER." 9956 PAUSE 4E4 9958 GOTO 9734 9976 SAVE "RENUMBER" 9978 FAST 9980 LET Z$="042000127205155009201033252037205216009035035035235042012064167237082235027114043115201" 9982 LET PA=32514 9984 FOR N=1 TO 87 STEP 3 9986 POKE PA,VAL Z$(N TO N+2) 9988 LET PA=PA+1 9990 NEXT N 9992 CLS 9993 LIST 9994 STOP 9996 RAND USR 32521 9999 GOTO 9992 ```