EXIT (BASIC 3.5)

From C64-Wiki
Jump to navigationJump to search
Stub This article is very short and not very detailed. Please help to improve it.
BASIC keyword
Keyword: EXIT
Abbreviation: exI
Type: Command
Token code: $ed 237
Handling routine
in BASIC ROM:
BASIC 3.5:
 ??–??
$??–??
BASIC 7.0:
 ??–??
$??–$??
List of all BASIC keywords


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

Type: Command
General Programming-Syntax: EXIT

The EXIT instruction is used to exit a DO LOOP loop prematurely. To do this, the loop information on the BASIC-Stack is removed and then the programme execution is continued immediately after the next LOOP command.Any open FOR NEXT loops are automatically removed from the stack.

If EXIT is called outside a DO-LOOP loop, this generates the error message ?LOOP WITHOUT DO ERROR.If the final LOOP command is not found, an ?LOOP NOT FOUND ERROR is output.Superfluous parameters following EXIT trigger an error status with the message ?SYNTAX ERROR.


Examples[edit | edit source]

DO: GETKEY A$: IF A$="X" THEN EXIT: LOOP

The loop is ending through the key "X".

10 DO
20 FOR I=1 TO 10000
30 PRINT I
40 GET A$: IF A$="X" THEN EXIT
50 NEXT I
60 LOOP WHILE 0

The numbers from 1 to 10000 are output. However, the output can be ended prematurely by pressing the "X" button. Combines the speed of a FOR-NEXT loop with the flexibility of the DO-LOOP construction.
As a side effect, the FOR-NEXT loop is also ended automatically (cleanly).

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