RESUME

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: RESUME
Abbreviation: RES Shift+U
Type: Command
Token code: $d6 (214)
Handling routine
in BASIC ROM:
UNK
List of all BASIC keywords


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

Type: Command
General Programming-Syntax: RESUME [line number | NEXT]

RESUME is used to return to normal execution after handling an error defined by TRAP. It is similar to using RETURN from a GOSUB, but can used only with TRAP.

There are three variations of RESUME. RESUME by itself will return to the start of the line where the error occurred. RESUME NEXT instead returns to the statement after the one that caused the error. This is perhaps the most common form. Finally, RESUME <line number> will resume at the given line number and is otherwise identical to a GOTO.

All three variations have the effect of clearing out the error and resetting the system in preparation for the next error that might occur. There are cases where you might want to leave the error "active" at the end of the error handler code, like if you want to return to the main code and process the error number or string there. In this case, you would not want to use RESUME and use GOTO instead.

A RESUME that is encountered without a TRAP being set will return an error ?CAN'T RESUME ERROR. A line number not in range 0 to 65535 produces a ?ILLEGAL QUANTITY ERROR.
A special case might arise with RESUME itself is the cause of an error which happens if the line number does not exist. Under BASIC 7.0 this leads to another call of the error handling routine according to TRAP, whereas BASIC 3.5 sees a permanent error and stops executing with ?UNDEF'D STATEMENT ERROR.
There no use to call this command in direct mode and the interpreter responds with ?ILLEGAL DIRECT ERROR.
Any usage not according to the above stated syntax gives a ?SYNTAX ERROR.

The line number style of this command is also corrected in the event of a RENUMBER.

Example[edit | edit source]

100 TRAP 2000
105 FOR I=1 TO 2000: NEXT : REM WAIT APPROX 2 SECS
110 FATAL SYNTAX ERROR : PRINT " ... CONTINUED"
120 END
2000 REM TRAP CATCH-UP ROUTINE
2010 PRINT ER; ERR$(ER) " ERROR IN LINE" EL "!"
2020 RESUME NEXT

This program's output should be

 11 SYNTAX ERROR IN LINE 110 !
 ... CONTINUED


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