RENUMBER (BASIC 3.5)

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: RENUMBER
Abbreviation: REN Shift+U
Type: Command
Token code: 248/$F8
Handling routine
in BASIC ROM:
BASIC 3.5:
 ??–??
$??–??
BASIC 7.0:
 ??–??
$??–$??
List of all BASIC keywords


Remark: This article describes the BASIC command RENUMBER in Commodore BASIC V3.5 or higher.

(Author's note: this information is correct for BASIC V7.0 on the Commodore 128, and is sourced from the C128 System guide. I assume it's the same for V3.5 - 7?)

Type: Command
General Programming-Syntax: RENUMBER [<new starting line number>][,<increment>][,<old starting line number>]

RENUMBER is a BASIC 3.5 command which renumbers the lines in the BASIC program currently in memory, changing any references to line numbers in e.g GOTO/GOSUB commands to point to the new line number.

If the starting line and increment parameters are not provided, they will both default to 10.

If the old starting line number parameter is not provided, the entire program is renumbered.

Note: You should save your program before renumbering! - very large programs may cause a system crash when RENUMBERed with large line numbers.

Note 2: RENUMBER can be slow - to RENUMBER a large program on the C128, FAST mode is recommended - according to the system guide, it may take up to 30 minutes to RENUMBER a 55K program in FAST mode. If you only have a 40-column monitor, you can do this by typing FAST RENUMBER <params> <return> and then SLOW <return>.


Errors


  • The BASIC line numbers can be used only in the range from 0 to 63999. A LINE NUMBER TOO LARGE error occurs if renumber generates a line number of 64000 or greater.
  • This command cannot be used in BASIC programs and will raise a DIRECT MODE ONLY ERROR if called from a program.
  • When using the old starting line number parameter, certain combinations of starting number and old starting number would affect program flow. In this case (where starting line number is lower than old starting line number and program lines exist between the two), RENUMBER will raise an ILLEGAL QUANTITY ERROR and the program numbering will not be affected.
  • An UNRESOLVED REFERENCE ERROR occurs if any reference to a line number which does not exist is encountered
  • An OUT OF MEMORY ERROR occurs if RENUMBER expands the program beyond its limits.

Examples[edit | edit source]

renumber the entire program with the new start and increment both 10:

RENUMBER

renumber the entire program with the new start and increment both 1 (i.e crunching line numbers):

RENUMBER 1,1

renumber lines >=100, moving them to line 1000, with an increment of 5

RENUMBER 1000,5,100

given the following program:

5 print "first line"
10 print "second line"
11 print "third line"
1038 print "fourth line"

cause an illegal quantity error because renumbering would affect program flow:

RENUMBER 1,1,11


BASIC V3.5 Commands

ABS | ASC | ATN | AUTO | BACKUP | BOX | CHAR | CHR$ | CIRCLE | CLOSE | CLR | CMD | COLLECT | COLOR | CONT | COPY | COS | DATA | DEC | DEF | DELETE | DIM | DIRECTORY | DLOAD | DO | DRAW | DS | DS$ | DSAVE | END | EL | ELSE | ER | ERR$ | EXIT | EXP | FN | FOR | FRE | GET | GET# | GETKEY | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | INSTR | INT | JOY | KEY | LEFT$ | LEN | LET | LIST | LOAD | LOCATE | LOG | LOOP | MID$ | MONITOR | NEW | NEXT | ON | OPEN | PAINT | PEEK | POKE | POS | PRINT | PRINT USING | PRINT# | PUDEF | RCLR | RDOT | READ | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | RLUM | RND | RUN | SAVE | SCALE | SCNCLR | SCRATCH | SGN | SIN | SOUND | SPC | SQR | SSHAPE | STOP | STR$ | SYS | TAB | TAN | TRAP | TROFF | TRON | UNTIL | USR | VAL | VERIFY | VOL | WHILE | WAIT